target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void testIsoTimeSecZ() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "2009-02-20T08:40:01Z"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().create(); interpreter.interpretTemporal(er, tr); assertEquals(2009, tr.getYear().intValue()); assertEquals(2, tr.getMonth().intValue()); assertEquals(20, tr.getDay().intValue()); assertEquals("2009-02-20T08:40:01Z", tr.getEventDate().getGte()); assertNull(tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test public void testIsoTimeMillisecZero() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "2002-03-10T00:00:00.0"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().create(); interpreter.interpretTemporal(er, tr); assertEquals(2002, tr.getYear().intValue()); assertEquals(3, tr.getMonth().intValue()); assertEquals(10, tr.getDay().intValue()); assertEquals("2002-03-10T00:00", tr.getEventDate().getGte()); assertNull(tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test public void testIsoTimeZone() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "2018-09-19T08:50+1000"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().create(); interpreter.interpretTemporal(er, tr); assertEquals(2018, tr.getYear().intValue()); assertEquals(9, tr.getMonth().intValue()); assertEquals(19, tr.getDay().intValue()); assertEquals("2018-09-19T08:50+10:00", tr.getEventDate().getGte()); assertNull(tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test public void testIsoTimeZoneMillisec() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "2013-11-06T19:59:14.961+1000"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().create(); interpreter.interpretTemporal(er, tr); assertEquals(2013, tr.getYear().intValue()); assertEquals(11, tr.getMonth().intValue()); assertEquals(6, tr.getDay().intValue()); assertEquals("2013-11-06T19:59:14.961+10:00", tr.getEventDate().getGte()); assertNull(tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test public void testIsoTimeMillisec() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "2013-11-06T19:59:14.961"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().create(); interpreter.interpretTemporal(er, tr); assertEquals(2013, tr.getYear().intValue()); assertEquals(11, tr.getMonth().intValue()); assertEquals(6, tr.getDay().intValue()); assertEquals("2013-11-06T19:59:14.961", tr.getEventDate().getGte()); assertNull(tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test(expected = IllegalArgumentException.class) public void countIndexDocumentsEmptyIndexTest() { EsIndex.countDocuments(EsConfig.from(DUMMY_HOST), ""); thrown.expectMessage("index is required"); }
|
public static long countDocuments(EsConfig config, String index) { Preconditions.checkArgument(!Strings.isNullOrEmpty(index), "index is required"); log.info("Counting documents from index {}", index); try (EsClient esClient = EsClient.from(config)) { return EsService.countIndexDocuments(esClient, index); } }
|
EsIndex { public static long countDocuments(EsConfig config, String index) { Preconditions.checkArgument(!Strings.isNullOrEmpty(index), "index is required"); log.info("Counting documents from index {}", index); try (EsClient esClient = EsClient.from(config)) { return EsService.countIndexDocuments(esClient, index); } } }
|
EsIndex { public static long countDocuments(EsConfig config, String index) { Preconditions.checkArgument(!Strings.isNullOrEmpty(index), "index is required"); log.info("Counting documents from index {}", index); try (EsClient esClient = EsClient.from(config)) { return EsService.countIndexDocuments(esClient, index); } } }
|
EsIndex { public static long countDocuments(EsConfig config, String index) { Preconditions.checkArgument(!Strings.isNullOrEmpty(index), "index is required"); log.info("Counting documents from index {}", index); try (EsClient esClient = EsClient.from(config)) { return EsService.countIndexDocuments(esClient, index); } } static String createIndex(EsConfig config, IndexParams indexParams); static Optional<String> createIndexIfNotExists(EsConfig config, IndexParams indexParams); static void swapIndexInAliases(EsConfig config, Set<String> aliases, String index); static void swapIndexInAliases(
EsConfig config,
Set<String> aliases,
String index,
Set<String> extraIdxToRemove,
Map<String, String> settings); static long countDocuments(EsConfig config, String index); static Set<String> deleteRecordsByDatasetId(
EsConfig config,
String[] aliases,
String datasetKey,
Predicate<String> indexesToDelete,
int timeoutSec,
int attempts); static Set<String> findDatasetIndexesInAliases(
EsConfig config, String[] aliases, String datasetKey); }
|
EsIndex { public static long countDocuments(EsConfig config, String index) { Preconditions.checkArgument(!Strings.isNullOrEmpty(index), "index is required"); log.info("Counting documents from index {}", index); try (EsClient esClient = EsClient.from(config)) { return EsService.countIndexDocuments(esClient, index); } } static String createIndex(EsConfig config, IndexParams indexParams); static Optional<String> createIndexIfNotExists(EsConfig config, IndexParams indexParams); static void swapIndexInAliases(EsConfig config, Set<String> aliases, String index); static void swapIndexInAliases(
EsConfig config,
Set<String> aliases,
String index,
Set<String> extraIdxToRemove,
Map<String, String> settings); static long countDocuments(EsConfig config, String index); static Set<String> deleteRecordsByDatasetId(
EsConfig config,
String[] aliases,
String datasetKey,
Predicate<String> indexesToDelete,
int timeoutSec,
int attempts); static Set<String> findDatasetIndexesInAliases(
EsConfig config, String[] aliases, String datasetKey); }
|
@Test public void testIsoTimeZoneMinute() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "2001-03-14T00:00:00-11:00"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().create(); interpreter.interpretTemporal(er, tr); assertEquals(2001, tr.getYear().intValue()); assertEquals(3, tr.getMonth().intValue()); assertEquals(14, tr.getDay().intValue()); assertEquals("2001-03-14T00:00-11:00", tr.getEventDate().getGte()); assertNull(tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test public void testIsoTimeMinuteZone() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "2001-03-14T00:00:00+11"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().create(); interpreter.interpretTemporal(er, tr); assertEquals(2001, tr.getYear().intValue()); assertEquals(3, tr.getMonth().intValue()); assertEquals(14, tr.getDay().intValue()); assertEquals("2001-03-14T00:00+11:00", tr.getEventDate().getGte()); assertNull(tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test public void testIsoTextMonth() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "1978-December-01"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().create(); interpreter.interpretTemporal(er, tr); assertEquals(1978, tr.getYear().intValue()); assertEquals(12, tr.getMonth().intValue()); assertEquals(1, tr.getDay().intValue()); assertEquals("1978-12-01", tr.getEventDate().getGte()); assertNull(tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test public void testIsoRangeYmd() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "2004-11-01/2005-02-01"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().create(); interpreter.interpretTemporal(er, tr); assertEquals(2004, tr.getYear().intValue()); assertEquals(11, tr.getMonth().intValue()); assertEquals(1, tr.getDay().intValue()); assertEquals("2004-11-01", tr.getEventDate().getGte()); assertEquals("2005-02-01", tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test public void testDmy() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "05-02-1978"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().orderings(Arrays.asList(DMY_FORMATS)).create(); interpreter.interpretTemporal(er, tr); assertEquals(1978, tr.getYear().intValue()); assertEquals(2, tr.getMonth().intValue()); assertEquals(5, tr.getDay().intValue()); assertEquals("1978-02-05", tr.getEventDate().getGte()); assertNull(tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test public void testIsoRangeMonthDay() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "1998-9-30/10-7"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().create(); interpreter.interpretTemporal(er, tr); assertEquals(1998, tr.getYear().intValue()); assertEquals(9, tr.getMonth().intValue()); assertEquals(30, tr.getDay().intValue()); assertEquals("1998-09-30", tr.getEventDate().getGte()); assertEquals("1998-10-07", tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test public void testIsoRangeShortDateWithoutZero() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "1998-9-7/30"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().create(); interpreter.interpretTemporal(er, tr); assertEquals(1998, tr.getYear().intValue()); assertEquals(9, tr.getMonth().intValue()); assertEquals(7, tr.getDay().intValue()); assertEquals("1998-09-07", tr.getEventDate().getGte()); assertEquals("1998-09-30", tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test public void testIsoRangeShortDate() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "1998-09-07/30"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().create(); interpreter.interpretTemporal(er, tr); assertEquals(1998, tr.getYear().intValue()); assertEquals(9, tr.getMonth().intValue()); assertEquals(7, tr.getDay().intValue()); assertEquals("1998-09-07", tr.getEventDate().getGte()); assertEquals("1998-09-30", tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test public void testShortYear() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "05/02/78"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().orderings(Arrays.asList(DMY_FORMATS)).create(); interpreter.interpretTemporal(er, tr); assertNull(tr.getYear()); assertNull(tr.getMonth()); assertNull(tr.getDay()); assertNull(tr.getEventDate().getGte()); assertNull(tr.getEventDate().getLte()); assertEquals(1, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test public void testExtraZeroFn() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "2011-05-00"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); SerializableFunction<String, String> fn = v -> { if (StringUtils.isNotEmpty(v)) { return v.replaceAll("-00", ""); } return v; }; TemporalInterpreter interpreter = TemporalInterpreter.builder().preprocessDateFn(fn).create(); interpreter.interpretTemporal(er, tr); assertEquals(2011, tr.getYear().intValue()); assertEquals(5, tr.getMonth().intValue()); assertNull(tr.getDay()); assertEquals("2011-05", tr.getEventDate().getGte()); assertNull(tr.getEventDate().getLte()); assertEquals(0, tr.getIssues().getIssueList().size()); }
|
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private TemporalInterpreter(
List<DateComponentOrdering> orderings,
SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
|
@Test(expected = NullPointerException.class) public void createClientFromNullConfigTest() { EsClient.from(null); }
|
public static EsClient from(EsConfig config) { return new EsClient(config); }
|
EsClient implements AutoCloseable { public static EsClient from(EsConfig config) { return new EsClient(config); } }
|
EsClient implements AutoCloseable { public static EsClient from(EsConfig config) { return new EsClient(config); } private EsClient(EsConfig config); }
|
EsClient implements AutoCloseable { public static EsClient from(EsConfig config) { return new EsClient(config); } private EsClient(EsConfig config); static EsClient from(EsConfig config); Response performGetRequest(String endpoint); Response performPutRequest(String endpoint, Map<String, String> params, HttpEntity body); Response performPostRequest(String endpoint, Map<String, String> params, HttpEntity body); Response performDeleteRequest(String endpoint); @Override @SneakyThrows void close(); }
|
EsClient implements AutoCloseable { public static EsClient from(EsConfig config) { return new EsClient(config); } private EsClient(EsConfig config); static EsClient from(EsConfig config); Response performGetRequest(String endpoint); Response performPutRequest(String endpoint, Map<String, String> params, HttpEntity body); Response performPostRequest(String endpoint, Map<String, String> params, HttpEntity body); Response performDeleteRequest(String endpoint); @Override @SneakyThrows void close(); }
|
@Test public void shouldUpdateLinkUnderMaintenanceFlag() throws SwitchNotFoundException { Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build(); switchRepository.add(sw); switchOperationsService.updateSwitchUnderMaintenanceFlag(TEST_SWITCH_ID, true); sw = switchRepository.findById(TEST_SWITCH_ID).get(); assertTrue(sw.isUnderMaintenance()); switchOperationsService.updateSwitchUnderMaintenanceFlag(TEST_SWITCH_ID, false); sw = switchRepository.findById(TEST_SWITCH_ID).get(); assertFalse(sw.isUnderMaintenance()); }
|
public Switch updateSwitchUnderMaintenanceFlag(SwitchId switchId, boolean underMaintenance) throws SwitchNotFoundException { return transactionManager.doInTransaction(() -> { Optional<Switch> foundSwitch = switchRepository.findById(switchId); if (!(foundSwitch.isPresent())) { return Optional.<Switch>empty(); } Switch sw = foundSwitch.get(); if (sw.isUnderMaintenance() == underMaintenance) { switchRepository.detach(sw); return Optional.of(sw); } sw.setUnderMaintenance(underMaintenance); linkOperationsService.getAllIsls(switchId, null, null, null) .forEach(isl -> { try { linkOperationsService.updateLinkUnderMaintenanceFlag( isl.getSrcSwitchId(), isl.getSrcPort(), isl.getDestSwitchId(), isl.getDestPort(), underMaintenance); } catch (IslNotFoundException e) { } }); switchRepository.detach(sw); return Optional.of(sw); }).orElseThrow(() -> new SwitchNotFoundException(switchId)); }
|
SwitchOperationsService implements ILinkOperationsServiceCarrier { public Switch updateSwitchUnderMaintenanceFlag(SwitchId switchId, boolean underMaintenance) throws SwitchNotFoundException { return transactionManager.doInTransaction(() -> { Optional<Switch> foundSwitch = switchRepository.findById(switchId); if (!(foundSwitch.isPresent())) { return Optional.<Switch>empty(); } Switch sw = foundSwitch.get(); if (sw.isUnderMaintenance() == underMaintenance) { switchRepository.detach(sw); return Optional.of(sw); } sw.setUnderMaintenance(underMaintenance); linkOperationsService.getAllIsls(switchId, null, null, null) .forEach(isl -> { try { linkOperationsService.updateLinkUnderMaintenanceFlag( isl.getSrcSwitchId(), isl.getSrcPort(), isl.getDestSwitchId(), isl.getDestPort(), underMaintenance); } catch (IslNotFoundException e) { } }); switchRepository.detach(sw); return Optional.of(sw); }).orElseThrow(() -> new SwitchNotFoundException(switchId)); } }
|
SwitchOperationsService implements ILinkOperationsServiceCarrier { public Switch updateSwitchUnderMaintenanceFlag(SwitchId switchId, boolean underMaintenance) throws SwitchNotFoundException { return transactionManager.doInTransaction(() -> { Optional<Switch> foundSwitch = switchRepository.findById(switchId); if (!(foundSwitch.isPresent())) { return Optional.<Switch>empty(); } Switch sw = foundSwitch.get(); if (sw.isUnderMaintenance() == underMaintenance) { switchRepository.detach(sw); return Optional.of(sw); } sw.setUnderMaintenance(underMaintenance); linkOperationsService.getAllIsls(switchId, null, null, null) .forEach(isl -> { try { linkOperationsService.updateLinkUnderMaintenanceFlag( isl.getSrcSwitchId(), isl.getSrcPort(), isl.getDestSwitchId(), isl.getDestPort(), underMaintenance); } catch (IslNotFoundException e) { } }); switchRepository.detach(sw); return Optional.of(sw); }).orElseThrow(() -> new SwitchNotFoundException(switchId)); } SwitchOperationsService(RepositoryFactory repositoryFactory,
TransactionManager transactionManager,
SwitchOperationsServiceCarrier carrier); }
|
SwitchOperationsService implements ILinkOperationsServiceCarrier { public Switch updateSwitchUnderMaintenanceFlag(SwitchId switchId, boolean underMaintenance) throws SwitchNotFoundException { return transactionManager.doInTransaction(() -> { Optional<Switch> foundSwitch = switchRepository.findById(switchId); if (!(foundSwitch.isPresent())) { return Optional.<Switch>empty(); } Switch sw = foundSwitch.get(); if (sw.isUnderMaintenance() == underMaintenance) { switchRepository.detach(sw); return Optional.of(sw); } sw.setUnderMaintenance(underMaintenance); linkOperationsService.getAllIsls(switchId, null, null, null) .forEach(isl -> { try { linkOperationsService.updateLinkUnderMaintenanceFlag( isl.getSrcSwitchId(), isl.getSrcPort(), isl.getDestSwitchId(), isl.getDestPort(), underMaintenance); } catch (IslNotFoundException e) { } }); switchRepository.detach(sw); return Optional.of(sw); }).orElseThrow(() -> new SwitchNotFoundException(switchId)); } SwitchOperationsService(RepositoryFactory repositoryFactory,
TransactionManager transactionManager,
SwitchOperationsServiceCarrier carrier); GetSwitchResponse getSwitch(SwitchId switchId); List<GetSwitchResponse> getAllSwitches(); Switch updateSwitchUnderMaintenanceFlag(SwitchId switchId, boolean underMaintenance); boolean deleteSwitch(SwitchId switchId, boolean force); void checkSwitchIsDeactivated(SwitchId switchId); void checkSwitchHasNoFlows(SwitchId switchId); void checkSwitchHasNoFlowSegments(SwitchId switchId); void checkSwitchHasNoIsls(SwitchId switchId); SwitchPropertiesDto getSwitchProperties(SwitchId switchId); SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto); PortProperties getPortProperties(SwitchId switchId, int port); Collection<SwitchConnectedDevice> getSwitchConnectedDevices(
SwitchId switchId); List<IslEndpoint> getSwitchIslEndpoints(SwitchId switchId); Switch patchSwitch(SwitchId switchId, SwitchPatch data); }
|
SwitchOperationsService implements ILinkOperationsServiceCarrier { public Switch updateSwitchUnderMaintenanceFlag(SwitchId switchId, boolean underMaintenance) throws SwitchNotFoundException { return transactionManager.doInTransaction(() -> { Optional<Switch> foundSwitch = switchRepository.findById(switchId); if (!(foundSwitch.isPresent())) { return Optional.<Switch>empty(); } Switch sw = foundSwitch.get(); if (sw.isUnderMaintenance() == underMaintenance) { switchRepository.detach(sw); return Optional.of(sw); } sw.setUnderMaintenance(underMaintenance); linkOperationsService.getAllIsls(switchId, null, null, null) .forEach(isl -> { try { linkOperationsService.updateLinkUnderMaintenanceFlag( isl.getSrcSwitchId(), isl.getSrcPort(), isl.getDestSwitchId(), isl.getDestPort(), underMaintenance); } catch (IslNotFoundException e) { } }); switchRepository.detach(sw); return Optional.of(sw); }).orElseThrow(() -> new SwitchNotFoundException(switchId)); } SwitchOperationsService(RepositoryFactory repositoryFactory,
TransactionManager transactionManager,
SwitchOperationsServiceCarrier carrier); GetSwitchResponse getSwitch(SwitchId switchId); List<GetSwitchResponse> getAllSwitches(); Switch updateSwitchUnderMaintenanceFlag(SwitchId switchId, boolean underMaintenance); boolean deleteSwitch(SwitchId switchId, boolean force); void checkSwitchIsDeactivated(SwitchId switchId); void checkSwitchHasNoFlows(SwitchId switchId); void checkSwitchHasNoFlowSegments(SwitchId switchId); void checkSwitchHasNoIsls(SwitchId switchId); SwitchPropertiesDto getSwitchProperties(SwitchId switchId); SwitchPropertiesDto updateSwitchProperties(SwitchId switchId, SwitchPropertiesDto switchPropertiesDto); PortProperties getPortProperties(SwitchId switchId, int port); Collection<SwitchConnectedDevice> getSwitchConnectedDevices(
SwitchId switchId); List<IslEndpoint> getSwitchIslEndpoints(SwitchId switchId); Switch patchSwitch(SwitchId switchId, SwitchPatch data); }
|
@Test public void installIntermediateIngressRule() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installIntermediateIngressRule(dpid, 1); OFFlowMod result = capture.getValue(); assertEquals(scheme.installIntermediateIngressRule(dpid, 1), result); }
|
@Override public long installIntermediateIngressRule(DatapathId dpid, int port) throws SwitchOperationException { IOFSwitch sw = lookupSwitch(dpid); OFFlowMod flowMod = buildIntermediateIngressRule(dpid, port); String flowName = "--Customer Port intermediate rule--" + dpid.toString(); pushFlow(sw, flowName, flowMod); return flowMod.getCookie().getValue(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIntermediateIngressRule(DatapathId dpid, int port) throws SwitchOperationException { IOFSwitch sw = lookupSwitch(dpid); OFFlowMod flowMod = buildIntermediateIngressRule(dpid, port); String flowName = "--Customer Port intermediate rule--" + dpid.toString(); pushFlow(sw, flowName, flowMod); return flowMod.getCookie().getValue(); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIntermediateIngressRule(DatapathId dpid, int port) throws SwitchOperationException { IOFSwitch sw = lookupSwitch(dpid); OFFlowMod flowMod = buildIntermediateIngressRule(dpid, port); String flowName = "--Customer Port intermediate rule--" + dpid.toString(); pushFlow(sw, flowName, flowMod); return flowMod.getCookie().getValue(); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIntermediateIngressRule(DatapathId dpid, int port) throws SwitchOperationException { IOFSwitch sw = lookupSwitch(dpid); OFFlowMod flowMod = buildIntermediateIngressRule(dpid, port); String flowName = "--Customer Port intermediate rule--" + dpid.toString(); pushFlow(sw, flowName, flowMod); return flowMod.getCookie().getValue(); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIntermediateIngressRule(DatapathId dpid, int port) throws SwitchOperationException { IOFSwitch sw = lookupSwitch(dpid); OFFlowMod flowMod = buildIntermediateIngressRule(dpid, port); String flowName = "--Customer Port intermediate rule--" + dpid.toString(); pushFlow(sw, flowName, flowMod); return flowMod.getCookie().getValue(); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installPreIngressTablePassThroughDefaultRule() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installPreIngressTablePassThroughDefaultRule(dpid); OFFlowMod result = capture.getValue(); assertEquals(scheme.installPreIngressTablePassThroughDefaultRule(dpid), result); }
|
@Override public Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getTablePassThroughDefaultFlowGenerator( MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, INGRESS_TABLE_ID, PRE_INGRESS_TABLE_ID), "--Pass Through Pre Ingress Default Rule--"); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getTablePassThroughDefaultFlowGenerator( MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, INGRESS_TABLE_ID, PRE_INGRESS_TABLE_ID), "--Pass Through Pre Ingress Default Rule--"); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getTablePassThroughDefaultFlowGenerator( MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, INGRESS_TABLE_ID, PRE_INGRESS_TABLE_ID), "--Pass Through Pre Ingress Default Rule--"); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getTablePassThroughDefaultFlowGenerator( MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, INGRESS_TABLE_ID, PRE_INGRESS_TABLE_ID), "--Pass Through Pre Ingress Default Rule--"); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getTablePassThroughDefaultFlowGenerator( MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, INGRESS_TABLE_ID, PRE_INGRESS_TABLE_ID), "--Pass Through Pre Ingress Default Rule--"); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installEgressTablePassThroughDefaultRule() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installEgressTablePassThroughDefaultRule(dpid); OFFlowMod result = capture.getValue(); assertEquals(scheme.installEgressTablePassThroughDefaultRule(dpid), result); }
|
@Override public Long installEgressTablePassThroughDefaultRule(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getTablePassThroughDefaultFlowGenerator( MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, TRANSIT_TABLE_ID, EGRESS_TABLE_ID), "--Pass Through Egress Default Rule--"); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installEgressTablePassThroughDefaultRule(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getTablePassThroughDefaultFlowGenerator( MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, TRANSIT_TABLE_ID, EGRESS_TABLE_ID), "--Pass Through Egress Default Rule--"); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installEgressTablePassThroughDefaultRule(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getTablePassThroughDefaultFlowGenerator( MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, TRANSIT_TABLE_ID, EGRESS_TABLE_ID), "--Pass Through Egress Default Rule--"); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installEgressTablePassThroughDefaultRule(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getTablePassThroughDefaultFlowGenerator( MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, TRANSIT_TABLE_ID, EGRESS_TABLE_ID), "--Pass Through Egress Default Rule--"); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installEgressTablePassThroughDefaultRule(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getTablePassThroughDefaultFlowGenerator( MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, TRANSIT_TABLE_ID, EGRESS_TABLE_ID), "--Pass Through Egress Default Rule--"); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installRoundTripLatencyFlow() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installRoundTripLatencyFlow(dpid); OFFlowMod result = capture.getValue(); assertEquals(scheme.installRoundTripLatencyRule(dpid), result); }
|
@Override public Long installRoundTripLatencyFlow(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getRoundTripLatencyFlowGenerator(), "--RoundTripLatencyRule--"); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installRoundTripLatencyFlow(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getRoundTripLatencyFlowGenerator(), "--RoundTripLatencyRule--"); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installRoundTripLatencyFlow(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getRoundTripLatencyFlowGenerator(), "--RoundTripLatencyRule--"); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installRoundTripLatencyFlow(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getRoundTripLatencyFlowGenerator(), "--RoundTripLatencyRule--"); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installRoundTripLatencyFlow(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getRoundTripLatencyFlowGenerator(), "--RoundTripLatencyRule--"); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installBfdCatchFlow() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installBfdCatchFlow(defaultDpid); assertEquals(scheme.installBfdCatchRule(defaultDpid), capture.getValue()); }
|
@Override public Long installBfdCatchFlow(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getBfdCatchFlowGenerator(), "--CatchBfdRule--"); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installBfdCatchFlow(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getBfdCatchFlowGenerator(), "--CatchBfdRule--"); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installBfdCatchFlow(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getBfdCatchFlowGenerator(), "--CatchBfdRule--"); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installBfdCatchFlow(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getBfdCatchFlowGenerator(), "--CatchBfdRule--"); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installBfdCatchFlow(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getBfdCatchFlowGenerator(), "--CatchBfdRule--"); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installUnicastVerificationRuleVxlan() throws Exception { mockGetMetersRequest(Lists.newArrayList(broadcastMeterId), true, 10L); mockBarrierRequest(); expect(iofSwitch.write(anyObject(OFMeterMod.class))).andReturn(true).times(1); Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installUnicastVerificationRuleVxlan(defaultDpid); assertEquals(scheme.installUnicastVerificationRuleVxlan(defaultDpid), capture.getValue()); }
|
@Override public Long installUnicastVerificationRuleVxlan(final DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getUnicastVerificationVxlanFlowGenerator(), "--VerificationFlowVxlan--"); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installUnicastVerificationRuleVxlan(final DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getUnicastVerificationVxlanFlowGenerator(), "--VerificationFlowVxlan--"); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installUnicastVerificationRuleVxlan(final DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getUnicastVerificationVxlanFlowGenerator(), "--VerificationFlowVxlan--"); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installUnicastVerificationRuleVxlan(final DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getUnicastVerificationVxlanFlowGenerator(), "--VerificationFlowVxlan--"); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installUnicastVerificationRuleVxlan(final DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getUnicastVerificationVxlanFlowGenerator(), "--VerificationFlowVxlan--"); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installIngressFlowReplaceActionUsingTransitVlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; switchManager.installIngressFlow(dpid, EGRESS_SWITCH_DP_ID, cookieHex, cookie, inputPort, outputPort, inputVlanId, transitVlanId, OutputVlanType.REPLACE, meterId, encapsulationType, false); assertEquals( scheme.ingressReplaceFlowMod(dpid, inputPort, outputPort, inputVlanId, transitVlanId, meterId, cookie, encapsulationType, EGRESS_SWITCH_DP_ID), capture.getValue()); }
|
@Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installIngressFlowReplaceActionUsingVxlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.VXLAN; switchManager.installIngressFlow(dpid, EGRESS_SWITCH_DP_ID, cookieHex, cookie, inputPort, outputPort, inputVlanId, transitVlanId, OutputVlanType.REPLACE, meterId, encapsulationType, false); assertEquals( scheme.ingressReplaceFlowMod(dpid, inputPort, outputPort, inputVlanId, transitVlanId, meterId, cookie, encapsulationType, EGRESS_SWITCH_DP_ID), capture.getValue()); }
|
@Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installIngressFlowPopActionUsingTransitVlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; switchManager.installIngressFlow(dpid, EGRESS_SWITCH_DP_ID, cookieHex, cookie, inputPort, outputPort, inputVlanId, transitVlanId, OutputVlanType.POP, meterId, encapsulationType, false); assertEquals( scheme.ingressPopFlowMod(dpid, inputPort, outputPort, inputVlanId, transitVlanId, meterId, cookie, encapsulationType, EGRESS_SWITCH_DP_ID), capture.getValue()); }
|
@Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installIngressFlowPopActionUsingVxlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.VXLAN; switchManager.installIngressFlow(dpid, EGRESS_SWITCH_DP_ID, cookieHex, cookie, inputPort, outputPort, inputVlanId, transitVlanId, OutputVlanType.POP, meterId, encapsulationType, false); assertEquals( scheme.ingressPopFlowMod(dpid, inputPort, outputPort, inputVlanId, transitVlanId, meterId, cookie, encapsulationType, EGRESS_SWITCH_DP_ID), capture.getValue()); }
|
@Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldUpdateMaxLatencyPriorityAndPinnedFlowFields() throws FlowNotFoundException { String testFlowId = "flow_id"; Long maxLatency = 555L; Integer priority = 777; PathComputationStrategy pathComputationStrategy = PathComputationStrategy.LATENCY; String description = "new_description"; Flow flow = new TestFlowBuilder() .flowId(testFlowId) .srcSwitch(createSwitch(SWITCH_ID_1)) .srcPort(1) .srcVlan(10) .destSwitch(createSwitch(SWITCH_ID_2)) .destPort(2) .destVlan(11) .encapsulationType(FlowEncapsulationType.TRANSIT_VLAN) .pathComputationStrategy(PathComputationStrategy.COST) .description("description") .status(FlowStatus.UP) .build(); flowRepository.add(flow); FlowPatch receivedFlow = FlowPatch.builder() .flowId(testFlowId) .maxLatency(maxLatency) .priority(priority) .pinned(true) .targetPathComputationStrategy(pathComputationStrategy) .description("new_description") .build(); Flow updatedFlow = flowOperationsService.updateFlow(new FlowCarrierImpl(), receivedFlow); assertEquals(maxLatency, updatedFlow.getMaxLatency()); assertEquals(priority, updatedFlow.getPriority()); assertEquals(pathComputationStrategy, updatedFlow.getTargetPathComputationStrategy()); assertEquals(description, updatedFlow.getDescription()); assertTrue(updatedFlow.isPinned()); receivedFlow = FlowPatch.builder() .flowId(testFlowId) .build(); updatedFlow = flowOperationsService.updateFlow(new FlowCarrierImpl(), receivedFlow); assertEquals(maxLatency, updatedFlow.getMaxLatency()); assertEquals(priority, updatedFlow.getPriority()); assertEquals(pathComputationStrategy, updatedFlow.getTargetPathComputationStrategy()); assertEquals(description, updatedFlow.getDescription()); assertTrue(updatedFlow.isPinned()); }
|
public Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch) throws FlowNotFoundException { UpdateFlowResult updateFlowResult = transactionManager.doInTransaction(() -> { Optional<Flow> foundFlow = flowRepository.findById(flowPatch.getFlowId()); if (!foundFlow.isPresent()) { return Optional.<UpdateFlowResult>empty(); } Flow currentFlow = foundFlow.get(); final UpdateFlowResult.UpdateFlowResultBuilder result = prepareFlowUpdateResult(flowPatch, currentFlow); Optional.ofNullable(flowPatch.getMaxLatency()).ifPresent(currentFlow::setMaxLatency); Optional.ofNullable(flowPatch.getPriority()).ifPresent(currentFlow::setPriority); Optional.ofNullable(flowPatch.getPinned()).ifPresent(currentFlow::setPinned); Optional.ofNullable(flowPatch.getDescription()).ifPresent(currentFlow::setDescription); Optional.ofNullable(flowPatch.getTargetPathComputationStrategy()) .ifPresent(currentFlow::setTargetPathComputationStrategy); Optional.ofNullable(flowPatch.getPeriodicPings()).ifPresent(periodicPings -> { boolean oldPeriodicPings = currentFlow.isPeriodicPings(); currentFlow.setPeriodicPings(periodicPings); if (oldPeriodicPings != currentFlow.isPeriodicPings()) { carrier.emitPeriodicPingUpdate(flowPatch.getFlowId(), flowPatch.getPeriodicPings()); } }); flowDashboardLogger.onFlowPatchUpdate(currentFlow); return Optional.of(result.updatedFlow(currentFlow).build()); }).orElseThrow(() -> new FlowNotFoundException(flowPatch.getFlowId())); Flow updatedFlow = updateFlowResult.getUpdatedFlow(); if (updateFlowResult.isNeedUpdateFlow()) { FlowRequest flowRequest = RequestedFlowMapper.INSTANCE.toFlowRequest(updatedFlow); carrier.sendUpdateRequest(addChangedFields(flowRequest, flowPatch)); } else { carrier.sendNorthboundResponse(new FlowResponse(FlowMapper.INSTANCE.map(updatedFlow))); } return updateFlowResult.getUpdatedFlow(); }
|
FlowOperationsService { public Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch) throws FlowNotFoundException { UpdateFlowResult updateFlowResult = transactionManager.doInTransaction(() -> { Optional<Flow> foundFlow = flowRepository.findById(flowPatch.getFlowId()); if (!foundFlow.isPresent()) { return Optional.<UpdateFlowResult>empty(); } Flow currentFlow = foundFlow.get(); final UpdateFlowResult.UpdateFlowResultBuilder result = prepareFlowUpdateResult(flowPatch, currentFlow); Optional.ofNullable(flowPatch.getMaxLatency()).ifPresent(currentFlow::setMaxLatency); Optional.ofNullable(flowPatch.getPriority()).ifPresent(currentFlow::setPriority); Optional.ofNullable(flowPatch.getPinned()).ifPresent(currentFlow::setPinned); Optional.ofNullable(flowPatch.getDescription()).ifPresent(currentFlow::setDescription); Optional.ofNullable(flowPatch.getTargetPathComputationStrategy()) .ifPresent(currentFlow::setTargetPathComputationStrategy); Optional.ofNullable(flowPatch.getPeriodicPings()).ifPresent(periodicPings -> { boolean oldPeriodicPings = currentFlow.isPeriodicPings(); currentFlow.setPeriodicPings(periodicPings); if (oldPeriodicPings != currentFlow.isPeriodicPings()) { carrier.emitPeriodicPingUpdate(flowPatch.getFlowId(), flowPatch.getPeriodicPings()); } }); flowDashboardLogger.onFlowPatchUpdate(currentFlow); return Optional.of(result.updatedFlow(currentFlow).build()); }).orElseThrow(() -> new FlowNotFoundException(flowPatch.getFlowId())); Flow updatedFlow = updateFlowResult.getUpdatedFlow(); if (updateFlowResult.isNeedUpdateFlow()) { FlowRequest flowRequest = RequestedFlowMapper.INSTANCE.toFlowRequest(updatedFlow); carrier.sendUpdateRequest(addChangedFields(flowRequest, flowPatch)); } else { carrier.sendNorthboundResponse(new FlowResponse(FlowMapper.INSTANCE.map(updatedFlow))); } return updateFlowResult.getUpdatedFlow(); } }
|
FlowOperationsService { public Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch) throws FlowNotFoundException { UpdateFlowResult updateFlowResult = transactionManager.doInTransaction(() -> { Optional<Flow> foundFlow = flowRepository.findById(flowPatch.getFlowId()); if (!foundFlow.isPresent()) { return Optional.<UpdateFlowResult>empty(); } Flow currentFlow = foundFlow.get(); final UpdateFlowResult.UpdateFlowResultBuilder result = prepareFlowUpdateResult(flowPatch, currentFlow); Optional.ofNullable(flowPatch.getMaxLatency()).ifPresent(currentFlow::setMaxLatency); Optional.ofNullable(flowPatch.getPriority()).ifPresent(currentFlow::setPriority); Optional.ofNullable(flowPatch.getPinned()).ifPresent(currentFlow::setPinned); Optional.ofNullable(flowPatch.getDescription()).ifPresent(currentFlow::setDescription); Optional.ofNullable(flowPatch.getTargetPathComputationStrategy()) .ifPresent(currentFlow::setTargetPathComputationStrategy); Optional.ofNullable(flowPatch.getPeriodicPings()).ifPresent(periodicPings -> { boolean oldPeriodicPings = currentFlow.isPeriodicPings(); currentFlow.setPeriodicPings(periodicPings); if (oldPeriodicPings != currentFlow.isPeriodicPings()) { carrier.emitPeriodicPingUpdate(flowPatch.getFlowId(), flowPatch.getPeriodicPings()); } }); flowDashboardLogger.onFlowPatchUpdate(currentFlow); return Optional.of(result.updatedFlow(currentFlow).build()); }).orElseThrow(() -> new FlowNotFoundException(flowPatch.getFlowId())); Flow updatedFlow = updateFlowResult.getUpdatedFlow(); if (updateFlowResult.isNeedUpdateFlow()) { FlowRequest flowRequest = RequestedFlowMapper.INSTANCE.toFlowRequest(updatedFlow); carrier.sendUpdateRequest(addChangedFields(flowRequest, flowPatch)); } else { carrier.sendNorthboundResponse(new FlowResponse(FlowMapper.INSTANCE.map(updatedFlow))); } return updateFlowResult.getUpdatedFlow(); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); }
|
FlowOperationsService { public Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch) throws FlowNotFoundException { UpdateFlowResult updateFlowResult = transactionManager.doInTransaction(() -> { Optional<Flow> foundFlow = flowRepository.findById(flowPatch.getFlowId()); if (!foundFlow.isPresent()) { return Optional.<UpdateFlowResult>empty(); } Flow currentFlow = foundFlow.get(); final UpdateFlowResult.UpdateFlowResultBuilder result = prepareFlowUpdateResult(flowPatch, currentFlow); Optional.ofNullable(flowPatch.getMaxLatency()).ifPresent(currentFlow::setMaxLatency); Optional.ofNullable(flowPatch.getPriority()).ifPresent(currentFlow::setPriority); Optional.ofNullable(flowPatch.getPinned()).ifPresent(currentFlow::setPinned); Optional.ofNullable(flowPatch.getDescription()).ifPresent(currentFlow::setDescription); Optional.ofNullable(flowPatch.getTargetPathComputationStrategy()) .ifPresent(currentFlow::setTargetPathComputationStrategy); Optional.ofNullable(flowPatch.getPeriodicPings()).ifPresent(periodicPings -> { boolean oldPeriodicPings = currentFlow.isPeriodicPings(); currentFlow.setPeriodicPings(periodicPings); if (oldPeriodicPings != currentFlow.isPeriodicPings()) { carrier.emitPeriodicPingUpdate(flowPatch.getFlowId(), flowPatch.getPeriodicPings()); } }); flowDashboardLogger.onFlowPatchUpdate(currentFlow); return Optional.of(result.updatedFlow(currentFlow).build()); }).orElseThrow(() -> new FlowNotFoundException(flowPatch.getFlowId())); Flow updatedFlow = updateFlowResult.getUpdatedFlow(); if (updateFlowResult.isNeedUpdateFlow()) { FlowRequest flowRequest = RequestedFlowMapper.INSTANCE.toFlowRequest(updatedFlow); carrier.sendUpdateRequest(addChangedFields(flowRequest, flowPatch)); } else { carrier.sendNorthboundResponse(new FlowResponse(FlowMapper.INSTANCE.map(updatedFlow))); } return updateFlowResult.getUpdatedFlow(); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
FlowOperationsService { public Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch) throws FlowNotFoundException { UpdateFlowResult updateFlowResult = transactionManager.doInTransaction(() -> { Optional<Flow> foundFlow = flowRepository.findById(flowPatch.getFlowId()); if (!foundFlow.isPresent()) { return Optional.<UpdateFlowResult>empty(); } Flow currentFlow = foundFlow.get(); final UpdateFlowResult.UpdateFlowResultBuilder result = prepareFlowUpdateResult(flowPatch, currentFlow); Optional.ofNullable(flowPatch.getMaxLatency()).ifPresent(currentFlow::setMaxLatency); Optional.ofNullable(flowPatch.getPriority()).ifPresent(currentFlow::setPriority); Optional.ofNullable(flowPatch.getPinned()).ifPresent(currentFlow::setPinned); Optional.ofNullable(flowPatch.getDescription()).ifPresent(currentFlow::setDescription); Optional.ofNullable(flowPatch.getTargetPathComputationStrategy()) .ifPresent(currentFlow::setTargetPathComputationStrategy); Optional.ofNullable(flowPatch.getPeriodicPings()).ifPresent(periodicPings -> { boolean oldPeriodicPings = currentFlow.isPeriodicPings(); currentFlow.setPeriodicPings(periodicPings); if (oldPeriodicPings != currentFlow.isPeriodicPings()) { carrier.emitPeriodicPingUpdate(flowPatch.getFlowId(), flowPatch.getPeriodicPings()); } }); flowDashboardLogger.onFlowPatchUpdate(currentFlow); return Optional.of(result.updatedFlow(currentFlow).build()); }).orElseThrow(() -> new FlowNotFoundException(flowPatch.getFlowId())); Flow updatedFlow = updateFlowResult.getUpdatedFlow(); if (updateFlowResult.isNeedUpdateFlow()) { FlowRequest flowRequest = RequestedFlowMapper.INSTANCE.toFlowRequest(updatedFlow); carrier.sendUpdateRequest(addChangedFields(flowRequest, flowPatch)); } else { carrier.sendNorthboundResponse(new FlowResponse(FlowMapper.INSTANCE.map(updatedFlow))); } return updateFlowResult.getUpdatedFlow(); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
@Test public void installIngressFlowPushActionvUsingTransitVlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; switchManager.installIngressFlow(dpid, EGRESS_SWITCH_DP_ID, cookieHex, cookie, inputPort, outputPort, 0, transitVlanId, OutputVlanType.PUSH, meterId, encapsulationType, false); assertEquals( scheme.ingressPushFlowMod(dpid, inputPort, outputPort, transitVlanId, meterId, cookie, encapsulationType, EGRESS_SWITCH_DP_ID), capture.getValue()); }
|
@Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installIngressFlowPushActionUsingVxlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.VXLAN; switchManager.installIngressFlow(dpid, EGRESS_SWITCH_DP_ID, cookieHex, cookie, inputPort, outputPort, 0, transitVlanId, OutputVlanType.PUSH, meterId, encapsulationType, false); assertEquals( scheme.ingressPushFlowMod(dpid, inputPort, outputPort, transitVlanId, meterId, cookie, encapsulationType, EGRESS_SWITCH_DP_ID), capture.getValue()); }
|
@Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installIngressFlowNoneActionUsingTransitVlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; switchManager.installIngressFlow(dpid, EGRESS_SWITCH_DP_ID, cookieHex, cookie, inputPort, outputPort, 0, transitVlanId, OutputVlanType.NONE, meterId, encapsulationType, false); assertEquals( scheme.ingressNoneFlowMod(dpid, inputPort, outputPort, transitVlanId, meterId, cookie, encapsulationType, EGRESS_SWITCH_DP_ID), capture.getValue()); }
|
@Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installIngressFlowNoneActionUsingVxlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.VXLAN; switchManager.installIngressFlow(dpid, EGRESS_SWITCH_DP_ID, cookieHex, cookie, inputPort, outputPort, 0, transitVlanId, OutputVlanType.NONE, meterId, encapsulationType, false); assertEquals( scheme.ingressNoneFlowMod(dpid, inputPort, outputPort, transitVlanId, meterId, cookie, encapsulationType, EGRESS_SWITCH_DP_ID), capture.getValue()); }
|
@Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installIngressFlowWithoutResetCountsFlag() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(true); switchManager.installIngressFlow(dpid, EGRESS_SWITCH_DP_ID, cookieHex, cookie, inputPort, outputPort, 0, transitVlanId, OutputVlanType.NONE, meterId, FlowEncapsulationType.TRANSIT_VLAN, false); final OFFlowMod actual = capture.getValue(); assertThat(actual.getFlags().isEmpty(), is(true)); }
|
@Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(inputVlanTypeToOfActionList(ofFactory, transitTunnelId, outputVlanType, encapsulationType, dpid, dstDpid)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, "--InstallIngressFlow--", builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installEgressFlowNoneActionUsingTransitVlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; switchManager.installEgressFlow(dpid, cookieHex, cookie, inputPort, outputPort, transitVlanId, 0, OutputVlanType.NONE, encapsulationType, false); assertEquals( scheme.egressNoneFlowMod(dpid, inputPort, outputPort, transitVlanId, cookie, encapsulationType), capture.getValue()); }
|
@Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installEgressFlowNoneActionUsingVxlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; switchManager.installEgressFlow(dpid, cookieHex, cookie, inputPort, outputPort, transitVlanId, 0, OutputVlanType.NONE, encapsulationType, false); assertEquals( scheme.egressNoneFlowMod(dpid, inputPort, outputPort, transitVlanId, cookie, encapsulationType), capture.getValue()); }
|
@Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installEgressFlowPushActionUsingTransitVlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; switchManager.installEgressFlow(dpid, cookieHex, cookie, inputPort, outputPort, transitVlanId, outputVlanId, OutputVlanType.PUSH, encapsulationType, false); assertEquals( scheme.egressPushFlowMod(dpid, inputPort, outputPort, transitVlanId, outputVlanId, cookie, encapsulationType), capture.getValue()); }
|
@Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installEgressFlowPushActionUsingVxlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.VXLAN; switchManager.installEgressFlow(dpid, cookieHex, cookie, inputPort, outputPort, transitVlanId, outputVlanId, OutputVlanType.PUSH, encapsulationType, false); assertEquals( scheme.egressPushFlowMod(dpid, inputPort, outputPort, transitVlanId, outputVlanId, cookie, encapsulationType), capture.getValue()); }
|
@Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installEgressFlowPopActionUsingTransitVlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; switchManager.installEgressFlow(dpid, cookieHex, cookie, inputPort, outputPort, transitVlanId, 0, OutputVlanType.POP, encapsulationType, false); assertEquals( scheme.egressPopFlowMod(dpid, inputPort, outputPort, transitVlanId, cookie, encapsulationType), capture.getValue()); }
|
@Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldPrepareFlowUpdateResultWithChangedStrategy() { String flowId = "test_flow_id"; FlowPatch flowDto = FlowPatch.builder() .flowId(flowId) .maxLatency(100L) .pathComputationStrategy(PathComputationStrategy.COST) .build(); Flow flow = Flow.builder() .flowId(flowId) .srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()) .destSwitch(Switch.builder().switchId(new SwitchId(2)).build()) .pathComputationStrategy(PathComputationStrategy.MAX_LATENCY) .build(); UpdateFlowResult result = flowOperationsService.prepareFlowUpdateResult(flowDto, flow).build(); assertTrue(result.isNeedUpdateFlow()); }
|
@VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
@Test public void installEgressFlowPopActionUsingVxlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.VXLAN; switchManager.installEgressFlow(dpid, cookieHex, cookie, inputPort, outputPort, transitVlanId, 0, OutputVlanType.POP, encapsulationType, false); assertEquals( scheme.egressPopFlowMod(dpid, inputPort, outputPort, transitVlanId, cookie, encapsulationType), capture.getValue()); }
|
@Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installEgressFlowReplaceActionUsingTransitVlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; switchManager.installEgressFlow(dpid, cookieHex, cookie, inputPort, outputPort, transitVlanId, outputVlanId, OutputVlanType.REPLACE, encapsulationType, false); assertEquals( scheme.egressReplaceFlowMod(dpid, inputPort, outputPort, transitVlanId, outputVlanId, cookie, encapsulationType), capture.getValue()); }
|
@Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installEgressFlowReplaceActionUsingVxlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.VXLAN; switchManager.installEgressFlow(dpid, cookieHex, cookie, inputPort, outputPort, transitVlanId, outputVlanId, OutputVlanType.REPLACE, encapsulationType, false); assertEquals( scheme.egressReplaceFlowMod(dpid, inputPort, outputPort, transitVlanId, outputVlanId, cookie, encapsulationType), capture.getValue()); }
|
@Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); actionList.addAll(egressFlowActions(ofFactory, outputVlanId, outputVlanType, encapsulationType)); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? EGRESS_TABLE_ID : INPUT_TABLE_ID) .setMatch(matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType)) .setInstructions(ImmutableList.of(actions)) .build(); return pushFlow(sw, "--InstallEgressFlow--", flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installTransitFlowUsingTransitVlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; switchManager.installTransitFlow(dpid, cookieHex, cookie, inputPort, outputPort, transitVlanId, encapsulationType, false); assertEquals( scheme.transitFlowMod(inputPort, outputPort, transitVlanId, cookie, encapsulationType), capture.getValue()); }
|
@Override public long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Match match = matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? TRANSIT_TABLE_ID : INPUT_TABLE_ID) .setInstructions(ImmutableList.of(actions)) .setMatch(match) .build(); return pushFlow(sw, flowId, flowMod); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Match match = matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? TRANSIT_TABLE_ID : INPUT_TABLE_ID) .setInstructions(ImmutableList.of(actions)) .setMatch(match) .build(); return pushFlow(sw, flowId, flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Match match = matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? TRANSIT_TABLE_ID : INPUT_TABLE_ID) .setInstructions(ImmutableList.of(actions)) .setMatch(match) .build(); return pushFlow(sw, flowId, flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Match match = matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? TRANSIT_TABLE_ID : INPUT_TABLE_ID) .setInstructions(ImmutableList.of(actions)) .setMatch(match) .build(); return pushFlow(sw, flowId, flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Match match = matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? TRANSIT_TABLE_ID : INPUT_TABLE_ID) .setInstructions(ImmutableList.of(actions)) .setMatch(match) .build(); return pushFlow(sw, flowId, flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installTransitFlowUsingVxlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.VXLAN; switchManager.installTransitFlow(dpid, cookieHex, cookie, inputPort, outputPort, transitVlanId, encapsulationType, false); assertEquals( scheme.transitFlowMod(inputPort, outputPort, transitVlanId, cookie, encapsulationType), capture.getValue()); }
|
@Override public long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Match match = matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? TRANSIT_TABLE_ID : INPUT_TABLE_ID) .setInstructions(ImmutableList.of(actions)) .setMatch(match) .build(); return pushFlow(sw, flowId, flowMod); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Match match = matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? TRANSIT_TABLE_ID : INPUT_TABLE_ID) .setInstructions(ImmutableList.of(actions)) .setMatch(match) .build(); return pushFlow(sw, flowId, flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Match match = matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? TRANSIT_TABLE_ID : INPUT_TABLE_ID) .setInstructions(ImmutableList.of(actions)) .setMatch(match) .build(); return pushFlow(sw, flowId, flowMod); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Match match = matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? TRANSIT_TABLE_ID : INPUT_TABLE_ID) .setInstructions(ImmutableList.of(actions)) .setMatch(match) .build(); return pushFlow(sw, flowId, flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Match match = matchFlow(ofFactory, inputPort, transitTunnelId, encapsulationType); actionList.add(actionSetOutputPort(ofFactory, OFPort.of(outputPort))); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, FLOW_PRIORITY, multiTable ? TRANSIT_TABLE_ID : INPUT_TABLE_ID) .setInstructions(ImmutableList.of(actions)) .setMatch(match) .build(); return pushFlow(sw, flowId, flowMod); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installOneSwitchFlowReplaceAction() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installOneSwitchFlow(dpid, cookieHex, cookie, inputPort, outputPort, inputVlanId, outputVlanId, OutputVlanType.REPLACE, meterId, false); assertEquals( scheme.oneSwitchReplaceFlowMod(inputPort, outputPort, inputVlanId, outputVlanId, meterId, cookie), capture.getValue()); }
|
@Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installOneSwitchFlowPushAction() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installOneSwitchFlow(dpid, cookieHex, cookie, inputPort, outputPort, 0, outputVlanId, OutputVlanType.PUSH, meterId, false); assertEquals( scheme.oneSwitchPushFlowMod(inputPort, outputPort, outputVlanId, meterId, cookie), capture.getValue()); }
|
@Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installOneSwitchFlowPopAction() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installOneSwitchFlow(dpid, cookieHex, cookie, inputPort, outputPort, inputVlanId, 0, OutputVlanType.POP, meterId, false); assertEquals( scheme.oneSwitchPopFlowMod(inputPort, outputPort, inputVlanId, meterId, cookie), capture.getValue()); }
|
@Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installOneSwitchFlowNoneAction() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installOneSwitchFlow(dpid, cookieHex, cookie, inputPort, outputPort, 0, 0, OutputVlanType.NONE, meterId, false); assertEquals( scheme.oneSwitchNoneFlowMod(inputPort, outputPort, meterId, cookie), capture.getValue()); }
|
@Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void installOneSwitchFlowNoneActionWithoutResetCountsFlag() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(true); switchManager.installOneSwitchFlow(dpid, cookieHex, cookie, inputPort, outputPort, 0, 0, OutputVlanType.NONE, meterId, false); final OFFlowMod actual = capture.getValue(); assertThat(actual.getFlags().isEmpty(), is(true)); }
|
@Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) throws SwitchOperationException { List<OFAction> actionList = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFInstructionMeter meter = buildMeterInstruction(meterId, sw, actionList); actionList.addAll(pushSchemeOutputVlanTypeToOfActionList(ofFactory, outputVlanId, outputVlanType)); OFPort ofOutputPort = outputPort == inputPort ? OFPort.IN_PORT : OFPort.of(outputPort); actionList.add(actionSetOutputPort(ofFactory, ofOutputPort)); OFInstructionApplyActions actions = buildInstructionApplyActions(ofFactory, actionList); Match match = matchFlow(ofFactory, inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN); int flowPriority = getFlowPriority(inputVlanId); List<OFInstruction> instructions = createIngressFlowInstructions(ofFactory, meter, actions, multiTable); if (multiTable) { RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().oneSwitchFlowFlag(true), sw); OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata() .setMetadata(metadata.getValue()) .setMetadataMask(metadata.getMask()) .build(); instructions.add(writeMetadata); } OFFlowMod.Builder builder = prepareFlowModBuilder(ofFactory, cookie & FLOW_COOKIE_MASK, flowPriority, multiTable ? INGRESS_TABLE_ID : INPUT_TABLE_ID) .setInstructions(instructions) .setMatch(match); if (featureDetectorService.detectSwitch(sw).contains(SwitchFeature.RESET_COUNTS_FLAG)) { builder.setFlags(ImmutableSet.of(OFFlowModFlags.RESET_COUNTS)); } return pushFlow(sw, flowId, builder.build()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldPrepareFlowUpdateResultWithChangedMaxLatencyFirstCase() { String flowId = "test_flow_id"; FlowPatch flowDto = FlowPatch.builder() .flowId(flowId) .maxLatency(100L) .build(); Flow flow = Flow.builder() .flowId(flowId) .srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()) .destSwitch(Switch.builder().switchId(new SwitchId(2)).build()) .pathComputationStrategy(PathComputationStrategy.MAX_LATENCY) .build(); UpdateFlowResult result = flowOperationsService.prepareFlowUpdateResult(flowDto, flow).build(); assertTrue(result.isNeedUpdateFlow()); }
|
@VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
@Test public void dumpFlowTable() { }
|
@Override public List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid) throws SwitchNotFoundException { List<OFFlowStatsEntry> entries = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFFlowStatsRequest flowRequest = ofFactory.buildFlowStatsRequest() .setOutGroup(OFGroup.ANY) .setCookieMask(U64.ZERO) .build(); try { Future<List<OFFlowStatsReply>> future = sw.writeStatsRequest(flowRequest); List<OFFlowStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { entries = values.stream() .map(OFFlowStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get flow stats for {}.", dpid, e); throw new SwitchNotFoundException(dpid); } catch (InterruptedException e) { logger.error("Could not get flow stats for {}.", dpid, e); Thread.currentThread().interrupt(); throw new SwitchNotFoundException(dpid); } return entries; }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid) throws SwitchNotFoundException { List<OFFlowStatsEntry> entries = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFFlowStatsRequest flowRequest = ofFactory.buildFlowStatsRequest() .setOutGroup(OFGroup.ANY) .setCookieMask(U64.ZERO) .build(); try { Future<List<OFFlowStatsReply>> future = sw.writeStatsRequest(flowRequest); List<OFFlowStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { entries = values.stream() .map(OFFlowStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get flow stats for {}.", dpid, e); throw new SwitchNotFoundException(dpid); } catch (InterruptedException e) { logger.error("Could not get flow stats for {}.", dpid, e); Thread.currentThread().interrupt(); throw new SwitchNotFoundException(dpid); } return entries; } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid) throws SwitchNotFoundException { List<OFFlowStatsEntry> entries = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFFlowStatsRequest flowRequest = ofFactory.buildFlowStatsRequest() .setOutGroup(OFGroup.ANY) .setCookieMask(U64.ZERO) .build(); try { Future<List<OFFlowStatsReply>> future = sw.writeStatsRequest(flowRequest); List<OFFlowStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { entries = values.stream() .map(OFFlowStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get flow stats for {}.", dpid, e); throw new SwitchNotFoundException(dpid); } catch (InterruptedException e) { logger.error("Could not get flow stats for {}.", dpid, e); Thread.currentThread().interrupt(); throw new SwitchNotFoundException(dpid); } return entries; } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid) throws SwitchNotFoundException { List<OFFlowStatsEntry> entries = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFFlowStatsRequest flowRequest = ofFactory.buildFlowStatsRequest() .setOutGroup(OFGroup.ANY) .setCookieMask(U64.ZERO) .build(); try { Future<List<OFFlowStatsReply>> future = sw.writeStatsRequest(flowRequest); List<OFFlowStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { entries = values.stream() .map(OFFlowStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get flow stats for {}.", dpid, e); throw new SwitchNotFoundException(dpid); } catch (InterruptedException e) { logger.error("Could not get flow stats for {}.", dpid, e); Thread.currentThread().interrupt(); throw new SwitchNotFoundException(dpid); } return entries; } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid) throws SwitchNotFoundException { List<OFFlowStatsEntry> entries = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); OFFlowStatsRequest flowRequest = ofFactory.buildFlowStatsRequest() .setOutGroup(OFGroup.ANY) .setCookieMask(U64.ZERO) .build(); try { Future<List<OFFlowStatsReply>> future = sw.writeStatsRequest(flowRequest); List<OFFlowStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { entries = values.stream() .map(OFFlowStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get flow stats for {}.", dpid, e); throw new SwitchNotFoundException(dpid); } catch (InterruptedException e) { logger.error("Could not get flow stats for {}.", dpid, e); Thread.currentThread().interrupt(); throw new SwitchNotFoundException(dpid); } return entries; } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void dumpMeters() throws InterruptedException, ExecutionException, TimeoutException, SwitchOperationException { OFMeterConfig firstMeter = ofFactory.buildMeterConfig().setMeterId(1).build(); OFMeterConfig secondMeter = ofFactory.buildMeterConfig().setMeterId(2).build(); ListenableFuture<List<OFMeterConfigStatsReply>> ofStatsFuture = createMock(ListenableFuture.class); expect(ofStatsFuture.get(anyLong(), anyObject())).andStubReturn(Lists.newArrayList( ofFactory.buildMeterConfigStatsReply().setEntries(Lists.newArrayList(firstMeter)).build(), ofFactory.buildMeterConfigStatsReply().setEntries(Lists.newArrayList(secondMeter)).build())); expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(switchDescription.getManufacturerDescription()).andStubReturn(""); expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); expect(iofSwitch.writeStatsRequest(isA(OFMeterConfigStatsRequest.class))).andStubReturn(ofStatsFuture); replay(ofSwitchService, iofSwitch, switchDescription, ofStatsFuture); List<OFMeterConfig> meters = switchManager.dumpMeters(dpid); assertNotNull(meters); assertEquals(2, meters.size()); assertEquals(Sets.newHashSet(firstMeter, secondMeter), new HashSet<>(meters)); }
|
@Override public List<OFMeterConfig> dumpMeters(final DatapathId dpid) throws SwitchOperationException { List<OFMeterConfig> result = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); if (sw == null) { throw new IllegalArgumentException(format("Switch %s was not found", dpid)); } verifySwitchSupportsMeters(sw); OFFactory ofFactory = sw.getOFFactory(); OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest() .setMeterId(0xffffffff) .build(); try { ListenableFuture<List<OFMeterConfigStatsReply>> future = sw.writeStatsRequest(meterRequest); List<OFMeterConfigStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { result = values.stream() .map(OFMeterConfigStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get meter config stats for {}.", dpid, e); } catch (InterruptedException e) { logger.error("Could not get meter config stats for {}.", dpid, e); Thread.currentThread().interrupt(); } return result; }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFMeterConfig> dumpMeters(final DatapathId dpid) throws SwitchOperationException { List<OFMeterConfig> result = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); if (sw == null) { throw new IllegalArgumentException(format("Switch %s was not found", dpid)); } verifySwitchSupportsMeters(sw); OFFactory ofFactory = sw.getOFFactory(); OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest() .setMeterId(0xffffffff) .build(); try { ListenableFuture<List<OFMeterConfigStatsReply>> future = sw.writeStatsRequest(meterRequest); List<OFMeterConfigStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { result = values.stream() .map(OFMeterConfigStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get meter config stats for {}.", dpid, e); } catch (InterruptedException e) { logger.error("Could not get meter config stats for {}.", dpid, e); Thread.currentThread().interrupt(); } return result; } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFMeterConfig> dumpMeters(final DatapathId dpid) throws SwitchOperationException { List<OFMeterConfig> result = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); if (sw == null) { throw new IllegalArgumentException(format("Switch %s was not found", dpid)); } verifySwitchSupportsMeters(sw); OFFactory ofFactory = sw.getOFFactory(); OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest() .setMeterId(0xffffffff) .build(); try { ListenableFuture<List<OFMeterConfigStatsReply>> future = sw.writeStatsRequest(meterRequest); List<OFMeterConfigStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { result = values.stream() .map(OFMeterConfigStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get meter config stats for {}.", dpid, e); } catch (InterruptedException e) { logger.error("Could not get meter config stats for {}.", dpid, e); Thread.currentThread().interrupt(); } return result; } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFMeterConfig> dumpMeters(final DatapathId dpid) throws SwitchOperationException { List<OFMeterConfig> result = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); if (sw == null) { throw new IllegalArgumentException(format("Switch %s was not found", dpid)); } verifySwitchSupportsMeters(sw); OFFactory ofFactory = sw.getOFFactory(); OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest() .setMeterId(0xffffffff) .build(); try { ListenableFuture<List<OFMeterConfigStatsReply>> future = sw.writeStatsRequest(meterRequest); List<OFMeterConfigStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { result = values.stream() .map(OFMeterConfigStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get meter config stats for {}.", dpid, e); } catch (InterruptedException e) { logger.error("Could not get meter config stats for {}.", dpid, e); Thread.currentThread().interrupt(); } return result; } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFMeterConfig> dumpMeters(final DatapathId dpid) throws SwitchOperationException { List<OFMeterConfig> result = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); if (sw == null) { throw new IllegalArgumentException(format("Switch %s was not found", dpid)); } verifySwitchSupportsMeters(sw); OFFactory ofFactory = sw.getOFFactory(); OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest() .setMeterId(0xffffffff) .build(); try { ListenableFuture<List<OFMeterConfigStatsReply>> future = sw.writeStatsRequest(meterRequest); List<OFMeterConfigStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { result = values.stream() .map(OFMeterConfigStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get meter config stats for {}.", dpid, e); } catch (InterruptedException e) { logger.error("Could not get meter config stats for {}.", dpid, e); Thread.currentThread().interrupt(); } return result; } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void dumpMetersTimeoutException() throws SwitchOperationException, InterruptedException, ExecutionException, TimeoutException { ListenableFuture<List<OFMeterConfigStatsReply>> ofStatsFuture = createMock(ListenableFuture.class); expect(ofStatsFuture.get(anyLong(), anyObject())).andThrow(new TimeoutException()); expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(switchDescription.getManufacturerDescription()).andStubReturn(""); expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); expect(iofSwitch.writeStatsRequest(isA(OFMeterConfigStatsRequest.class))).andStubReturn(ofStatsFuture); replay(ofSwitchService, iofSwitch, switchDescription, ofStatsFuture); List<OFMeterConfig> meters = switchManager.dumpMeters(dpid); assertNotNull(meters); assertTrue(meters.isEmpty()); }
|
@Override public List<OFMeterConfig> dumpMeters(final DatapathId dpid) throws SwitchOperationException { List<OFMeterConfig> result = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); if (sw == null) { throw new IllegalArgumentException(format("Switch %s was not found", dpid)); } verifySwitchSupportsMeters(sw); OFFactory ofFactory = sw.getOFFactory(); OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest() .setMeterId(0xffffffff) .build(); try { ListenableFuture<List<OFMeterConfigStatsReply>> future = sw.writeStatsRequest(meterRequest); List<OFMeterConfigStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { result = values.stream() .map(OFMeterConfigStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get meter config stats for {}.", dpid, e); } catch (InterruptedException e) { logger.error("Could not get meter config stats for {}.", dpid, e); Thread.currentThread().interrupt(); } return result; }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFMeterConfig> dumpMeters(final DatapathId dpid) throws SwitchOperationException { List<OFMeterConfig> result = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); if (sw == null) { throw new IllegalArgumentException(format("Switch %s was not found", dpid)); } verifySwitchSupportsMeters(sw); OFFactory ofFactory = sw.getOFFactory(); OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest() .setMeterId(0xffffffff) .build(); try { ListenableFuture<List<OFMeterConfigStatsReply>> future = sw.writeStatsRequest(meterRequest); List<OFMeterConfigStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { result = values.stream() .map(OFMeterConfigStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get meter config stats for {}.", dpid, e); } catch (InterruptedException e) { logger.error("Could not get meter config stats for {}.", dpid, e); Thread.currentThread().interrupt(); } return result; } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFMeterConfig> dumpMeters(final DatapathId dpid) throws SwitchOperationException { List<OFMeterConfig> result = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); if (sw == null) { throw new IllegalArgumentException(format("Switch %s was not found", dpid)); } verifySwitchSupportsMeters(sw); OFFactory ofFactory = sw.getOFFactory(); OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest() .setMeterId(0xffffffff) .build(); try { ListenableFuture<List<OFMeterConfigStatsReply>> future = sw.writeStatsRequest(meterRequest); List<OFMeterConfigStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { result = values.stream() .map(OFMeterConfigStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get meter config stats for {}.", dpid, e); } catch (InterruptedException e) { logger.error("Could not get meter config stats for {}.", dpid, e); Thread.currentThread().interrupt(); } return result; } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFMeterConfig> dumpMeters(final DatapathId dpid) throws SwitchOperationException { List<OFMeterConfig> result = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); if (sw == null) { throw new IllegalArgumentException(format("Switch %s was not found", dpid)); } verifySwitchSupportsMeters(sw); OFFactory ofFactory = sw.getOFFactory(); OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest() .setMeterId(0xffffffff) .build(); try { ListenableFuture<List<OFMeterConfigStatsReply>> future = sw.writeStatsRequest(meterRequest); List<OFMeterConfigStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { result = values.stream() .map(OFMeterConfigStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get meter config stats for {}.", dpid, e); } catch (InterruptedException e) { logger.error("Could not get meter config stats for {}.", dpid, e); Thread.currentThread().interrupt(); } return result; } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFMeterConfig> dumpMeters(final DatapathId dpid) throws SwitchOperationException { List<OFMeterConfig> result = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); if (sw == null) { throw new IllegalArgumentException(format("Switch %s was not found", dpid)); } verifySwitchSupportsMeters(sw); OFFactory ofFactory = sw.getOFFactory(); OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest() .setMeterId(0xffffffff) .build(); try { ListenableFuture<List<OFMeterConfigStatsReply>> future = sw.writeStatsRequest(meterRequest); List<OFMeterConfigStatsReply> values = future.get(10, TimeUnit.SECONDS); if (values != null) { result = values.stream() .map(OFMeterConfigStatsReply::getEntries) .flatMap(List::stream) .collect(toList()); } } catch (ExecutionException | TimeoutException e) { logger.error("Could not get meter config stats for {}.", dpid, e); } catch (InterruptedException e) { logger.error("Could not get meter config stats for {}.", dpid, e); Thread.currentThread().interrupt(); } return result; } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void deleteMeter() throws Exception { mockBarrierRequest(); final Capture<OFMeterMod> capture = prepareForMeterTest(); switchManager.deleteMeter(dpid, meterId); final OFMeterMod meterMod = capture.getValue(); assertEquals(meterMod.getCommand(), OFMeterModCommand.DELETE); assertEquals(meterMod.getMeterId(), meterId); }
|
@Override public void deleteMeter(final DatapathId dpid, final long meterId) throws SwitchOperationException { if (meterId > 0L) { IOFSwitch sw = lookupSwitch(dpid); verifySwitchSupportsMeters(sw); buildAndDeleteMeter(sw, dpid, meterId); sendBarrierRequest(sw); } else { throw new InvalidMeterIdException(dpid, "Meter id must be positive."); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public void deleteMeter(final DatapathId dpid, final long meterId) throws SwitchOperationException { if (meterId > 0L) { IOFSwitch sw = lookupSwitch(dpid); verifySwitchSupportsMeters(sw); buildAndDeleteMeter(sw, dpid, meterId); sendBarrierRequest(sw); } else { throw new InvalidMeterIdException(dpid, "Meter id must be positive."); } } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public void deleteMeter(final DatapathId dpid, final long meterId) throws SwitchOperationException { if (meterId > 0L) { IOFSwitch sw = lookupSwitch(dpid); verifySwitchSupportsMeters(sw); buildAndDeleteMeter(sw, dpid, meterId); sendBarrierRequest(sw); } else { throw new InvalidMeterIdException(dpid, "Meter id must be positive."); } } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public void deleteMeter(final DatapathId dpid, final long meterId) throws SwitchOperationException { if (meterId > 0L) { IOFSwitch sw = lookupSwitch(dpid); verifySwitchSupportsMeters(sw); buildAndDeleteMeter(sw, dpid, meterId); sendBarrierRequest(sw); } else { throw new InvalidMeterIdException(dpid, "Meter id must be positive."); } } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public void deleteMeter(final DatapathId dpid, final long meterId) throws SwitchOperationException { if (meterId > 0L) { IOFSwitch sw = lookupSwitch(dpid); verifySwitchSupportsMeters(sw); buildAndDeleteMeter(sw, dpid, meterId); sendBarrierRequest(sw); } else { throw new InvalidMeterIdException(dpid, "Meter id must be positive."); } } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test(expected = InvalidMeterIdException.class) public void deleteMeterWithInvalidId() throws SwitchOperationException { switchManager.deleteMeter(dpid, -1); }
|
@Override public void deleteMeter(final DatapathId dpid, final long meterId) throws SwitchOperationException { if (meterId > 0L) { IOFSwitch sw = lookupSwitch(dpid); verifySwitchSupportsMeters(sw); buildAndDeleteMeter(sw, dpid, meterId); sendBarrierRequest(sw); } else { throw new InvalidMeterIdException(dpid, "Meter id must be positive."); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public void deleteMeter(final DatapathId dpid, final long meterId) throws SwitchOperationException { if (meterId > 0L) { IOFSwitch sw = lookupSwitch(dpid); verifySwitchSupportsMeters(sw); buildAndDeleteMeter(sw, dpid, meterId); sendBarrierRequest(sw); } else { throw new InvalidMeterIdException(dpid, "Meter id must be positive."); } } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public void deleteMeter(final DatapathId dpid, final long meterId) throws SwitchOperationException { if (meterId > 0L) { IOFSwitch sw = lookupSwitch(dpid); verifySwitchSupportsMeters(sw); buildAndDeleteMeter(sw, dpid, meterId); sendBarrierRequest(sw); } else { throw new InvalidMeterIdException(dpid, "Meter id must be positive."); } } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public void deleteMeter(final DatapathId dpid, final long meterId) throws SwitchOperationException { if (meterId > 0L) { IOFSwitch sw = lookupSwitch(dpid); verifySwitchSupportsMeters(sw); buildAndDeleteMeter(sw, dpid, meterId); sendBarrierRequest(sw); } else { throw new InvalidMeterIdException(dpid, "Meter id must be positive."); } } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public void deleteMeter(final DatapathId dpid, final long meterId) throws SwitchOperationException { if (meterId > 0L) { IOFSwitch sw = lookupSwitch(dpid); verifySwitchSupportsMeters(sw); buildAndDeleteMeter(sw, dpid, meterId); sendBarrierRequest(sw); } else { throw new InvalidMeterIdException(dpid, "Meter id must be positive."); } } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldDeleteAllNonDefaultRules() throws Exception { expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); Capture<OFFlowMod> capture = EasyMock.newCapture(); expect(iofSwitch.write(capture(capture))).andReturn(true); mockBarrierRequest(); mockFlowStatsRequest(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); expectLastCall(); replay(ofSwitchService, iofSwitch); List<Long> deletedRules = switchManager.deleteAllNonDefaultRules(dpid); final OFFlowMod actual = capture.getValue(); assertEquals(OFFlowModCommand.DELETE, actual.getCommand()); assertNull(actual.getMatch().get(MatchField.IN_PORT)); assertNull(actual.getMatch().get(MatchField.VLAN_VID)); assertEquals("any", actual.getOutPort().toString()); assertEquals(0, actual.getInstructions().size()); assertEquals(cookie, actual.getCookie().getValue()); assertEquals(U64.NO_MASK, actual.getCookieMask()); assertThat(deletedRules, containsInAnyOrder(cookie)); }
|
@Override public List<Long> deleteAllNonDefaultRules(final DatapathId dpid) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Set<Long> removedRules = new HashSet<>(); for (OFFlowStatsEntry flowStatsEntry : flowStatsBefore) { long flowCookie = flowStatsEntry.getCookie().getValue(); if (!isDefaultRule(flowCookie)) { OFFlowDelete flowDelete = ofFactory.buildFlowDelete() .setCookie(U64.of(flowCookie)) .setCookieMask(U64.NO_MASK) .setTableId(TableId.ALL) .build(); pushFlow(sw, "--DeleteFlow--", flowDelete); logger.info("Rule with cookie {} is to be removed from switch {}.", flowCookie, dpid); removedRules.add(flowCookie); } } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .filter(cookie -> !removedRules.contains(cookie)) .forEach(cookie -> { logger.warn("Rule with cookie {} has been removed although not requested. Switch {}.", cookie, dpid); removedRules.add(cookie); }); cookiesAfter.stream() .filter(removedRules::contains) .forEach(cookie -> { logger.warn("Rule with cookie {} was requested to be removed, but it still remains. Switch {}.", cookie, dpid); removedRules.remove(cookie); }); return new ArrayList<>(removedRules); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteAllNonDefaultRules(final DatapathId dpid) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Set<Long> removedRules = new HashSet<>(); for (OFFlowStatsEntry flowStatsEntry : flowStatsBefore) { long flowCookie = flowStatsEntry.getCookie().getValue(); if (!isDefaultRule(flowCookie)) { OFFlowDelete flowDelete = ofFactory.buildFlowDelete() .setCookie(U64.of(flowCookie)) .setCookieMask(U64.NO_MASK) .setTableId(TableId.ALL) .build(); pushFlow(sw, "--DeleteFlow--", flowDelete); logger.info("Rule with cookie {} is to be removed from switch {}.", flowCookie, dpid); removedRules.add(flowCookie); } } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .filter(cookie -> !removedRules.contains(cookie)) .forEach(cookie -> { logger.warn("Rule with cookie {} has been removed although not requested. Switch {}.", cookie, dpid); removedRules.add(cookie); }); cookiesAfter.stream() .filter(removedRules::contains) .forEach(cookie -> { logger.warn("Rule with cookie {} was requested to be removed, but it still remains. Switch {}.", cookie, dpid); removedRules.remove(cookie); }); return new ArrayList<>(removedRules); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteAllNonDefaultRules(final DatapathId dpid) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Set<Long> removedRules = new HashSet<>(); for (OFFlowStatsEntry flowStatsEntry : flowStatsBefore) { long flowCookie = flowStatsEntry.getCookie().getValue(); if (!isDefaultRule(flowCookie)) { OFFlowDelete flowDelete = ofFactory.buildFlowDelete() .setCookie(U64.of(flowCookie)) .setCookieMask(U64.NO_MASK) .setTableId(TableId.ALL) .build(); pushFlow(sw, "--DeleteFlow--", flowDelete); logger.info("Rule with cookie {} is to be removed from switch {}.", flowCookie, dpid); removedRules.add(flowCookie); } } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .filter(cookie -> !removedRules.contains(cookie)) .forEach(cookie -> { logger.warn("Rule with cookie {} has been removed although not requested. Switch {}.", cookie, dpid); removedRules.add(cookie); }); cookiesAfter.stream() .filter(removedRules::contains) .forEach(cookie -> { logger.warn("Rule with cookie {} was requested to be removed, but it still remains. Switch {}.", cookie, dpid); removedRules.remove(cookie); }); return new ArrayList<>(removedRules); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteAllNonDefaultRules(final DatapathId dpid) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Set<Long> removedRules = new HashSet<>(); for (OFFlowStatsEntry flowStatsEntry : flowStatsBefore) { long flowCookie = flowStatsEntry.getCookie().getValue(); if (!isDefaultRule(flowCookie)) { OFFlowDelete flowDelete = ofFactory.buildFlowDelete() .setCookie(U64.of(flowCookie)) .setCookieMask(U64.NO_MASK) .setTableId(TableId.ALL) .build(); pushFlow(sw, "--DeleteFlow--", flowDelete); logger.info("Rule with cookie {} is to be removed from switch {}.", flowCookie, dpid); removedRules.add(flowCookie); } } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .filter(cookie -> !removedRules.contains(cookie)) .forEach(cookie -> { logger.warn("Rule with cookie {} has been removed although not requested. Switch {}.", cookie, dpid); removedRules.add(cookie); }); cookiesAfter.stream() .filter(removedRules::contains) .forEach(cookie -> { logger.warn("Rule with cookie {} was requested to be removed, but it still remains. Switch {}.", cookie, dpid); removedRules.remove(cookie); }); return new ArrayList<>(removedRules); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteAllNonDefaultRules(final DatapathId dpid) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); Set<Long> removedRules = new HashSet<>(); for (OFFlowStatsEntry flowStatsEntry : flowStatsBefore) { long flowCookie = flowStatsEntry.getCookie().getValue(); if (!isDefaultRule(flowCookie)) { OFFlowDelete flowDelete = ofFactory.buildFlowDelete() .setCookie(U64.of(flowCookie)) .setCookieMask(U64.NO_MASK) .setTableId(TableId.ALL) .build(); pushFlow(sw, "--DeleteFlow--", flowDelete); logger.info("Rule with cookie {} is to be removed from switch {}.", flowCookie, dpid); removedRules.add(flowCookie); } } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .filter(cookie -> !removedRules.contains(cookie)) .forEach(cookie -> { logger.warn("Rule with cookie {} has been removed although not requested. Switch {}.", cookie, dpid); removedRules.add(cookie); }); cookiesAfter.stream() .filter(removedRules::contains) .forEach(cookie -> { logger.warn("Rule with cookie {} was requested to be removed, but it still remains. Switch {}.", cookie, dpid); removedRules.remove(cookie); }); return new ArrayList<>(removedRules); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldDeleteDefaultRulesWithoutMeters() throws Exception { expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(new OFFactoryVer12Mock()); expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription); expect(iofSwitch.getId()).andStubReturn(dpid); expect(switchDescription.getManufacturerDescription()).andStubReturn(OVS_MANUFACTURER); mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, DROP_VERIFICATION_LOOP_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, ROUND_TRIP_LATENCY_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE); Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL); expect(iofSwitch.write(capture(capture))).andReturn(true).times(27); expect(iofSwitch.write(isA(OFGroupDelete.class))).andReturn(true).once(); mockBarrierRequest(); mockFlowStatsRequest(cookie); expectLastCall(); replay(ofSwitchService, iofSwitch, switchDescription); List<Long> deletedRules = switchManager.deleteDefaultRules(dpid, Collections.emptyList(), Collections.emptyList(), Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), true, true, true, true); final List<OFFlowMod> actual = capture.getValues(); assertEquals(27, actual.size()); assertThat(actual, everyItem(hasProperty("command", equalTo(OFFlowModCommand.DELETE)))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(DROP_RULE_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(VERIFICATION_BROADCAST_RULE_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(VERIFICATION_UNICAST_RULE_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(DROP_VERIFICATION_LOOP_RULE_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(CATCH_BFD_RULE_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(ROUND_TRIP_LATENCY_RULE_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(MULTITABLE_INGRESS_DROP_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(MULTITABLE_POST_INGRESS_DROP_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(MULTITABLE_EGRESS_PASS_THROUGH_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(MULTITABLE_TRANSIT_DROP_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(LLDP_INPUT_PRE_DROP_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(LLDP_TRANSIT_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(LLDP_INGRESS_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(LLDP_POST_INGRESS_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(LLDP_POST_INGRESS_VXLAN_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(ARP_INPUT_PRE_DROP_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(ARP_TRANSIT_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(ARP_INGRESS_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(ARP_POST_INGRESS_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(ARP_POST_INGRESS_VXLAN_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(ARP_POST_INGRESS_ONE_SWITCH_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(SERVER_42_TURNING_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(SERVER_42_OUTPUT_VLAN_COOKIE))))); assertThat(actual, hasItem(hasProperty("cookie", equalTo(U64.of(SERVER_42_OUTPUT_VXLAN_COOKIE))))); assertThat(deletedRules, containsInAnyOrder(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, DROP_VERIFICATION_LOOP_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, ROUND_TRIP_LATENCY_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE)); }
|
@Override public List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts, List<Integer> flowPorts, Set<Integer> flowLldpPorts, Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts, boolean multiTable, boolean switchLldp, boolean switchArp, boolean server42FlowRtt) throws SwitchOperationException { List<Long> deletedRules = deleteRulesWithCookie(dpid, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, DROP_VERIFICATION_LOOP_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, ROUND_TRIP_LATENCY_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE); if (multiTable) { for (int islPort : islPorts) { deletedRules.addAll(removeMultitableEndpointIslRules(dpid, islPort)); } for (int flowPort : flowPorts) { deletedRules.add(removeIntermediateIngressRule(dpid, flowPort)); } for (int flowLldpPort : flowLldpPorts) { deletedRules.add(removeLldpInputCustomerFlow(dpid, flowLldpPort)); } for (int flowArpPort : flowArpPorts) { deletedRules.add(removeArpInputCustomerFlow(dpid, flowArpPort)); } if (server42FlowRtt) { for (Integer port : server42FlowRttPorts) { deletedRules.add(removeServer42InputFlow(dpid, port)); } } } try { deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); if (switchLldp) { deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INGRESS_COOKIE).getValue()); } if (switchArp) { deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INGRESS_COOKIE).getValue()); } } catch (UnsupportedSwitchOperationException e) { logger.info("Skip meters deletion from switch {} due to lack of meters support", dpid); } try { deleteGroup(lookupSwitch(dpid), ROUND_TRIP_LATENCY_GROUP_ID); } catch (OfInstallException e) { logger.info("Couldn't delete round trip latency group from switch {}. {}", dpid, e.getOfMessage()); } return deletedRules; }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts, List<Integer> flowPorts, Set<Integer> flowLldpPorts, Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts, boolean multiTable, boolean switchLldp, boolean switchArp, boolean server42FlowRtt) throws SwitchOperationException { List<Long> deletedRules = deleteRulesWithCookie(dpid, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, DROP_VERIFICATION_LOOP_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, ROUND_TRIP_LATENCY_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE); if (multiTable) { for (int islPort : islPorts) { deletedRules.addAll(removeMultitableEndpointIslRules(dpid, islPort)); } for (int flowPort : flowPorts) { deletedRules.add(removeIntermediateIngressRule(dpid, flowPort)); } for (int flowLldpPort : flowLldpPorts) { deletedRules.add(removeLldpInputCustomerFlow(dpid, flowLldpPort)); } for (int flowArpPort : flowArpPorts) { deletedRules.add(removeArpInputCustomerFlow(dpid, flowArpPort)); } if (server42FlowRtt) { for (Integer port : server42FlowRttPorts) { deletedRules.add(removeServer42InputFlow(dpid, port)); } } } try { deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); if (switchLldp) { deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INGRESS_COOKIE).getValue()); } if (switchArp) { deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INGRESS_COOKIE).getValue()); } } catch (UnsupportedSwitchOperationException e) { logger.info("Skip meters deletion from switch {} due to lack of meters support", dpid); } try { deleteGroup(lookupSwitch(dpid), ROUND_TRIP_LATENCY_GROUP_ID); } catch (OfInstallException e) { logger.info("Couldn't delete round trip latency group from switch {}. {}", dpid, e.getOfMessage()); } return deletedRules; } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts, List<Integer> flowPorts, Set<Integer> flowLldpPorts, Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts, boolean multiTable, boolean switchLldp, boolean switchArp, boolean server42FlowRtt) throws SwitchOperationException { List<Long> deletedRules = deleteRulesWithCookie(dpid, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, DROP_VERIFICATION_LOOP_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, ROUND_TRIP_LATENCY_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE); if (multiTable) { for (int islPort : islPorts) { deletedRules.addAll(removeMultitableEndpointIslRules(dpid, islPort)); } for (int flowPort : flowPorts) { deletedRules.add(removeIntermediateIngressRule(dpid, flowPort)); } for (int flowLldpPort : flowLldpPorts) { deletedRules.add(removeLldpInputCustomerFlow(dpid, flowLldpPort)); } for (int flowArpPort : flowArpPorts) { deletedRules.add(removeArpInputCustomerFlow(dpid, flowArpPort)); } if (server42FlowRtt) { for (Integer port : server42FlowRttPorts) { deletedRules.add(removeServer42InputFlow(dpid, port)); } } } try { deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); if (switchLldp) { deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INGRESS_COOKIE).getValue()); } if (switchArp) { deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INGRESS_COOKIE).getValue()); } } catch (UnsupportedSwitchOperationException e) { logger.info("Skip meters deletion from switch {} due to lack of meters support", dpid); } try { deleteGroup(lookupSwitch(dpid), ROUND_TRIP_LATENCY_GROUP_ID); } catch (OfInstallException e) { logger.info("Couldn't delete round trip latency group from switch {}. {}", dpid, e.getOfMessage()); } return deletedRules; } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts, List<Integer> flowPorts, Set<Integer> flowLldpPorts, Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts, boolean multiTable, boolean switchLldp, boolean switchArp, boolean server42FlowRtt) throws SwitchOperationException { List<Long> deletedRules = deleteRulesWithCookie(dpid, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, DROP_VERIFICATION_LOOP_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, ROUND_TRIP_LATENCY_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE); if (multiTable) { for (int islPort : islPorts) { deletedRules.addAll(removeMultitableEndpointIslRules(dpid, islPort)); } for (int flowPort : flowPorts) { deletedRules.add(removeIntermediateIngressRule(dpid, flowPort)); } for (int flowLldpPort : flowLldpPorts) { deletedRules.add(removeLldpInputCustomerFlow(dpid, flowLldpPort)); } for (int flowArpPort : flowArpPorts) { deletedRules.add(removeArpInputCustomerFlow(dpid, flowArpPort)); } if (server42FlowRtt) { for (Integer port : server42FlowRttPorts) { deletedRules.add(removeServer42InputFlow(dpid, port)); } } } try { deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); if (switchLldp) { deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INGRESS_COOKIE).getValue()); } if (switchArp) { deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INGRESS_COOKIE).getValue()); } } catch (UnsupportedSwitchOperationException e) { logger.info("Skip meters deletion from switch {} due to lack of meters support", dpid); } try { deleteGroup(lookupSwitch(dpid), ROUND_TRIP_LATENCY_GROUP_ID); } catch (OfInstallException e) { logger.info("Couldn't delete round trip latency group from switch {}. {}", dpid, e.getOfMessage()); } return deletedRules; } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts, List<Integer> flowPorts, Set<Integer> flowLldpPorts, Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts, boolean multiTable, boolean switchLldp, boolean switchArp, boolean server42FlowRtt) throws SwitchOperationException { List<Long> deletedRules = deleteRulesWithCookie(dpid, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, DROP_VERIFICATION_LOOP_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, ROUND_TRIP_LATENCY_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE); if (multiTable) { for (int islPort : islPorts) { deletedRules.addAll(removeMultitableEndpointIslRules(dpid, islPort)); } for (int flowPort : flowPorts) { deletedRules.add(removeIntermediateIngressRule(dpid, flowPort)); } for (int flowLldpPort : flowLldpPorts) { deletedRules.add(removeLldpInputCustomerFlow(dpid, flowLldpPort)); } for (int flowArpPort : flowArpPorts) { deletedRules.add(removeArpInputCustomerFlow(dpid, flowArpPort)); } if (server42FlowRtt) { for (Integer port : server42FlowRttPorts) { deletedRules.add(removeServer42InputFlow(dpid, port)); } } } try { deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); if (switchLldp) { deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INGRESS_COOKIE).getValue()); } if (switchArp) { deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INGRESS_COOKIE).getValue()); } } catch (UnsupportedSwitchOperationException e) { logger.info("Skip meters deletion from switch {} due to lack of meters support", dpid); } try { deleteGroup(lookupSwitch(dpid), ROUND_TRIP_LATENCY_GROUP_ID); } catch (OfInstallException e) { logger.info("Couldn't delete round trip latency group from switch {}. {}", dpid, e.getOfMessage()); } return deletedRules; } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldDeleteDefaultRulesWithMeters() throws Exception { expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription); expect(iofSwitch.getId()).andStubReturn(dpid); expect(switchDescription.getManufacturerDescription()).andStubReturn(StringUtils.EMPTY); mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE); Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL); expect(iofSwitch.write(capture(capture))).andReturn(true).times(43); expect(iofSwitch.write(isA(OFGroupDelete.class))).andReturn(true).once(); mockBarrierRequest(); mockFlowStatsRequest(cookie); mockGetMetersRequest(Collections.emptyList(), true, 0); replay(ofSwitchService, iofSwitch, switchDescription); List<Long> deletedRules = switchManager.deleteDefaultRules(dpid, Collections.emptyList(), Collections.emptyList(), Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), true, true, true, true); assertThat(deletedRules, containsInAnyOrder(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE)); final List<OFFlowMod> actual = capture.getValues(); assertEquals(43, actual.size()); List<OFFlowMod> rulesMod = actual.subList(0, 27); assertThat(rulesMod, everyItem(hasProperty("command", equalTo(OFFlowModCommand.DELETE)))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(DROP_RULE_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(VERIFICATION_BROADCAST_RULE_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(VERIFICATION_UNICAST_RULE_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(DROP_VERIFICATION_LOOP_RULE_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(CATCH_BFD_RULE_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(ROUND_TRIP_LATENCY_RULE_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of( MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(MULTITABLE_INGRESS_DROP_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(MULTITABLE_POST_INGRESS_DROP_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(MULTITABLE_EGRESS_PASS_THROUGH_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(MULTITABLE_TRANSIT_DROP_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(LLDP_INPUT_PRE_DROP_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(LLDP_TRANSIT_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(LLDP_INGRESS_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(LLDP_POST_INGRESS_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(LLDP_POST_INGRESS_VXLAN_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(ARP_INPUT_PRE_DROP_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(ARP_TRANSIT_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(ARP_INGRESS_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(ARP_POST_INGRESS_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(ARP_POST_INGRESS_VXLAN_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(ARP_POST_INGRESS_ONE_SWITCH_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(SERVER_42_TURNING_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(SERVER_42_OUTPUT_VLAN_COOKIE))))); assertThat(rulesMod, hasItem(hasProperty("cookie", equalTo(U64.of(SERVER_42_OUTPUT_VXLAN_COOKIE))))); List<OFFlowMod> metersMod = actual.subList(rulesMod.size(), rulesMod.size() + 15); assertThat(metersMod, everyItem(hasProperty("command", equalTo(OFMeterModCommand.DELETE)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(broadcastMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(unicastMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(unicastVxlanMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(lldpPreDropMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(lldpTransitMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(lldpIngressMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(lldpPostIngressMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(lldpPostIngressVxlanMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(lldpPostIngressOneSwitchMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(arpPreDropMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(arpTransitMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(arpIngressMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(arpPostIngressMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(arpPostIngressVxlanMeterId)))); assertThat(metersMod, hasItem(hasProperty("meterId", equalTo(arpPostIngressOneSwitchMeterId)))); List<OFFlowMod> groupMod = actual.subList(rulesMod.size() + metersMod.size(), actual.size()); assertThat(groupMod, everyItem(hasProperty("command", equalTo(OFGroupModCommand.DELETE)))); assertThat(groupMod, hasItem(hasProperty("group", equalTo(OFGroup.of(ROUND_TRIP_LATENCY_GROUP_ID))))); }
|
@Override public List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts, List<Integer> flowPorts, Set<Integer> flowLldpPorts, Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts, boolean multiTable, boolean switchLldp, boolean switchArp, boolean server42FlowRtt) throws SwitchOperationException { List<Long> deletedRules = deleteRulesWithCookie(dpid, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, DROP_VERIFICATION_LOOP_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, ROUND_TRIP_LATENCY_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE); if (multiTable) { for (int islPort : islPorts) { deletedRules.addAll(removeMultitableEndpointIslRules(dpid, islPort)); } for (int flowPort : flowPorts) { deletedRules.add(removeIntermediateIngressRule(dpid, flowPort)); } for (int flowLldpPort : flowLldpPorts) { deletedRules.add(removeLldpInputCustomerFlow(dpid, flowLldpPort)); } for (int flowArpPort : flowArpPorts) { deletedRules.add(removeArpInputCustomerFlow(dpid, flowArpPort)); } if (server42FlowRtt) { for (Integer port : server42FlowRttPorts) { deletedRules.add(removeServer42InputFlow(dpid, port)); } } } try { deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); if (switchLldp) { deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INGRESS_COOKIE).getValue()); } if (switchArp) { deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INGRESS_COOKIE).getValue()); } } catch (UnsupportedSwitchOperationException e) { logger.info("Skip meters deletion from switch {} due to lack of meters support", dpid); } try { deleteGroup(lookupSwitch(dpid), ROUND_TRIP_LATENCY_GROUP_ID); } catch (OfInstallException e) { logger.info("Couldn't delete round trip latency group from switch {}. {}", dpid, e.getOfMessage()); } return deletedRules; }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts, List<Integer> flowPorts, Set<Integer> flowLldpPorts, Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts, boolean multiTable, boolean switchLldp, boolean switchArp, boolean server42FlowRtt) throws SwitchOperationException { List<Long> deletedRules = deleteRulesWithCookie(dpid, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, DROP_VERIFICATION_LOOP_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, ROUND_TRIP_LATENCY_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE); if (multiTable) { for (int islPort : islPorts) { deletedRules.addAll(removeMultitableEndpointIslRules(dpid, islPort)); } for (int flowPort : flowPorts) { deletedRules.add(removeIntermediateIngressRule(dpid, flowPort)); } for (int flowLldpPort : flowLldpPorts) { deletedRules.add(removeLldpInputCustomerFlow(dpid, flowLldpPort)); } for (int flowArpPort : flowArpPorts) { deletedRules.add(removeArpInputCustomerFlow(dpid, flowArpPort)); } if (server42FlowRtt) { for (Integer port : server42FlowRttPorts) { deletedRules.add(removeServer42InputFlow(dpid, port)); } } } try { deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); if (switchLldp) { deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INGRESS_COOKIE).getValue()); } if (switchArp) { deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INGRESS_COOKIE).getValue()); } } catch (UnsupportedSwitchOperationException e) { logger.info("Skip meters deletion from switch {} due to lack of meters support", dpid); } try { deleteGroup(lookupSwitch(dpid), ROUND_TRIP_LATENCY_GROUP_ID); } catch (OfInstallException e) { logger.info("Couldn't delete round trip latency group from switch {}. {}", dpid, e.getOfMessage()); } return deletedRules; } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts, List<Integer> flowPorts, Set<Integer> flowLldpPorts, Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts, boolean multiTable, boolean switchLldp, boolean switchArp, boolean server42FlowRtt) throws SwitchOperationException { List<Long> deletedRules = deleteRulesWithCookie(dpid, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, DROP_VERIFICATION_LOOP_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, ROUND_TRIP_LATENCY_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE); if (multiTable) { for (int islPort : islPorts) { deletedRules.addAll(removeMultitableEndpointIslRules(dpid, islPort)); } for (int flowPort : flowPorts) { deletedRules.add(removeIntermediateIngressRule(dpid, flowPort)); } for (int flowLldpPort : flowLldpPorts) { deletedRules.add(removeLldpInputCustomerFlow(dpid, flowLldpPort)); } for (int flowArpPort : flowArpPorts) { deletedRules.add(removeArpInputCustomerFlow(dpid, flowArpPort)); } if (server42FlowRtt) { for (Integer port : server42FlowRttPorts) { deletedRules.add(removeServer42InputFlow(dpid, port)); } } } try { deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); if (switchLldp) { deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INGRESS_COOKIE).getValue()); } if (switchArp) { deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INGRESS_COOKIE).getValue()); } } catch (UnsupportedSwitchOperationException e) { logger.info("Skip meters deletion from switch {} due to lack of meters support", dpid); } try { deleteGroup(lookupSwitch(dpid), ROUND_TRIP_LATENCY_GROUP_ID); } catch (OfInstallException e) { logger.info("Couldn't delete round trip latency group from switch {}. {}", dpid, e.getOfMessage()); } return deletedRules; } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts, List<Integer> flowPorts, Set<Integer> flowLldpPorts, Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts, boolean multiTable, boolean switchLldp, boolean switchArp, boolean server42FlowRtt) throws SwitchOperationException { List<Long> deletedRules = deleteRulesWithCookie(dpid, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, DROP_VERIFICATION_LOOP_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, ROUND_TRIP_LATENCY_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE); if (multiTable) { for (int islPort : islPorts) { deletedRules.addAll(removeMultitableEndpointIslRules(dpid, islPort)); } for (int flowPort : flowPorts) { deletedRules.add(removeIntermediateIngressRule(dpid, flowPort)); } for (int flowLldpPort : flowLldpPorts) { deletedRules.add(removeLldpInputCustomerFlow(dpid, flowLldpPort)); } for (int flowArpPort : flowArpPorts) { deletedRules.add(removeArpInputCustomerFlow(dpid, flowArpPort)); } if (server42FlowRtt) { for (Integer port : server42FlowRttPorts) { deletedRules.add(removeServer42InputFlow(dpid, port)); } } } try { deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); if (switchLldp) { deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INGRESS_COOKIE).getValue()); } if (switchArp) { deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INGRESS_COOKIE).getValue()); } } catch (UnsupportedSwitchOperationException e) { logger.info("Skip meters deletion from switch {} due to lack of meters support", dpid); } try { deleteGroup(lookupSwitch(dpid), ROUND_TRIP_LATENCY_GROUP_ID); } catch (OfInstallException e) { logger.info("Couldn't delete round trip latency group from switch {}. {}", dpid, e.getOfMessage()); } return deletedRules; } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts, List<Integer> flowPorts, Set<Integer> flowLldpPorts, Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts, boolean multiTable, boolean switchLldp, boolean switchArp, boolean server42FlowRtt) throws SwitchOperationException { List<Long> deletedRules = deleteRulesWithCookie(dpid, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE, DROP_VERIFICATION_LOOP_RULE_COOKIE, CATCH_BFD_RULE_COOKIE, ROUND_TRIP_LATENCY_RULE_COOKIE, VERIFICATION_UNICAST_VXLAN_RULE_COOKIE, MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE, MULTITABLE_INGRESS_DROP_COOKIE, MULTITABLE_POST_INGRESS_DROP_COOKIE, MULTITABLE_EGRESS_PASS_THROUGH_COOKIE, MULTITABLE_TRANSIT_DROP_COOKIE, LLDP_INPUT_PRE_DROP_COOKIE, LLDP_TRANSIT_COOKIE, LLDP_INGRESS_COOKIE, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_INPUT_PRE_DROP_COOKIE, ARP_TRANSIT_COOKIE, ARP_INGRESS_COOKIE, ARP_POST_INGRESS_COOKIE, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, SERVER_42_OUTPUT_VLAN_COOKIE, SERVER_42_OUTPUT_VXLAN_COOKIE, SERVER_42_TURNING_COOKIE); if (multiTable) { for (int islPort : islPorts) { deletedRules.addAll(removeMultitableEndpointIslRules(dpid, islPort)); } for (int flowPort : flowPorts) { deletedRules.add(removeIntermediateIngressRule(dpid, flowPort)); } for (int flowLldpPort : flowLldpPorts) { deletedRules.add(removeLldpInputCustomerFlow(dpid, flowLldpPort)); } for (int flowArpPort : flowArpPorts) { deletedRules.add(removeArpInputCustomerFlow(dpid, flowArpPort)); } if (server42FlowRtt) { for (Integer port : server42FlowRttPorts) { deletedRules.add(removeServer42InputFlow(dpid, port)); } } } try { deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_VXLAN_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_POST_INGRESS_ONE_SWITCH_COOKIE).getValue()); if (switchLldp) { deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(LLDP_INGRESS_COOKIE).getValue()); } if (switchArp) { deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INPUT_PRE_DROP_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_TRANSIT_COOKIE).getValue()); deleteMeter(dpid, createMeterIdForDefaultRule(ARP_INGRESS_COOKIE).getValue()); } } catch (UnsupportedSwitchOperationException e) { logger.info("Skip meters deletion from switch {} due to lack of meters support", dpid); } try { deleteGroup(lookupSwitch(dpid), ROUND_TRIP_LATENCY_GROUP_ID); } catch (OfInstallException e) { logger.info("Couldn't delete round trip latency group from switch {}. {}", dpid, e.getOfMessage()); } return deletedRules; } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldDeleteRuleByCookie() throws Exception { expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL); expect(iofSwitch.write(capture(capture))).andReturn(true).times(3); mockBarrierRequest(); mockFlowStatsRequest(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); expectLastCall(); replay(ofSwitchService, iofSwitch); DeleteRulesCriteria criteria = DeleteRulesCriteria.builder().cookie(cookie).build(); List<Long> deletedRules = switchManager.deleteRulesByCriteria(dpid, false, null, criteria); final OFFlowMod actual = capture.getValue(); assertEquals(OFFlowModCommand.DELETE, actual.getCommand()); assertNull(actual.getMatch().get(MatchField.IN_PORT)); assertNull(actual.getMatch().get(MatchField.VLAN_VID)); assertEquals("any", actual.getOutPort().toString()); assertEquals(0, actual.getInstructions().size()); assertEquals(cookie, actual.getCookie().getValue()); assertEquals(U64.NO_MASK, actual.getCookieMask()); assertThat(deletedRules, containsInAnyOrder(cookie)); }
|
@Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldDeleteRuleByInPort() throws Exception { final int testInPort = 11; expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL); expect(iofSwitch.write(capture(capture))).andReturn(true).times(3); mockBarrierRequest(); mockFlowStatsRequest(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); expectLastCall(); replay(ofSwitchService, iofSwitch); DeleteRulesCriteria criteria = DeleteRulesCriteria.builder().inPort(testInPort) .encapsulationType(FlowEncapsulationType.TRANSIT_VLAN) .egressSwitchId(SWITCH_ID).build(); List<Long> deletedRules = switchManager.deleteRulesByCriteria(dpid, false, null, criteria); final OFFlowMod actual = capture.getValue(); assertEquals(OFFlowModCommand.DELETE, actual.getCommand()); assertEquals(testInPort, actual.getMatch().get(MatchField.IN_PORT).getPortNumber()); assertNull(actual.getMatch().get(MatchField.VLAN_VID)); assertEquals("any", actual.getOutPort().toString()); assertEquals(0, actual.getInstructions().size()); assertEquals(0L, actual.getCookie().getValue()); assertEquals(0L, actual.getCookieMask().getValue()); assertThat(deletedRules, containsInAnyOrder(cookie)); }
|
@Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldPrepareFlowUpdateResultWithChangedMaxLatencySecondCase() { String flowId = "test_flow_id"; FlowPatch flowDto = FlowPatch.builder() .flowId(flowId) .maxLatency(100L) .pathComputationStrategy(PathComputationStrategy.MAX_LATENCY) .build(); Flow flow = Flow.builder() .flowId(flowId) .srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()) .destSwitch(Switch.builder().switchId(new SwitchId(2)).build()) .pathComputationStrategy(PathComputationStrategy.MAX_LATENCY) .build(); UpdateFlowResult result = flowOperationsService.prepareFlowUpdateResult(flowDto, flow).build(); assertTrue(result.isNeedUpdateFlow()); }
|
@VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
@Test public void shouldDeleteRuleByInVlan() throws Exception { final short testInVlan = 101; FlowEncapsulationType flowEncapsulationType = FlowEncapsulationType.TRANSIT_VLAN; expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL); expect(iofSwitch.write(capture(capture))).andReturn(true).times(3); mockBarrierRequest(); mockFlowStatsRequest(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); expectLastCall(); replay(ofSwitchService, iofSwitch); DeleteRulesCriteria criteria = DeleteRulesCriteria.builder().encapsulationId((int) testInVlan) .encapsulationType(flowEncapsulationType).build(); List<Long> deletedRules = switchManager.deleteRulesByCriteria(dpid, false, null, criteria); final OFFlowMod actual = capture.getValue(); assertEquals(OFFlowModCommand.DELETE, actual.getCommand()); assertEquals(testInVlan, actual.getMatch().get(MatchField.VLAN_VID).getVlan()); assertNull(actual.getMatch().get(MatchField.IN_PORT)); assertEquals("any", actual.getOutPort().toString()); assertEquals(0, actual.getInstructions().size()); assertEquals(0L, actual.getCookie().getValue()); assertEquals(0L, actual.getCookieMask().getValue()); assertThat(deletedRules, containsInAnyOrder(cookie)); }
|
@Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldDeleteRuleByInPortAndVlan() throws Exception { final int testInPort = 11; final short testInVlan = 101; expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL); expect(iofSwitch.write(capture(capture))).andReturn(true).times(3); mockBarrierRequest(); mockFlowStatsRequest(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); expectLastCall(); replay(ofSwitchService, iofSwitch); DeleteRulesCriteria criteria = DeleteRulesCriteria.builder() .inPort(testInPort) .encapsulationId((int) testInVlan) .encapsulationType(FlowEncapsulationType.TRANSIT_VLAN) .egressSwitchId(SWITCH_ID) .build(); List<Long> deletedRules = switchManager.deleteRulesByCriteria(dpid, false, null, criteria); final OFFlowMod actual = capture.getValue(); assertEquals(OFFlowModCommand.DELETE, actual.getCommand()); assertEquals(testInPort, actual.getMatch().get(MatchField.IN_PORT).getPortNumber()); assertEquals(testInVlan, actual.getMatch().get(MatchField.VLAN_VID).getVlan()); assertEquals("any", actual.getOutPort().toString()); assertEquals(0, actual.getInstructions().size()); assertEquals(0L, actual.getCookie().getValue()); assertEquals(0L, actual.getCookieMask().getValue()); assertThat(deletedRules, containsInAnyOrder(cookie)); }
|
@Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldDeleteRuleByInPortAndVxlanTunnel() throws Exception { final int testInPort = 11; final short testInVlan = 101; expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL); expect(iofSwitch.write(capture(capture))).andReturn(true).times(3); mockBarrierRequest(); mockFlowStatsRequest(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); expectLastCall(); replay(ofSwitchService, iofSwitch); DeleteRulesCriteria criteria = DeleteRulesCriteria.builder() .inPort(testInPort) .encapsulationId((int) testInVlan) .encapsulationType(FlowEncapsulationType.VXLAN) .egressSwitchId(SWITCH_ID) .build(); List<Long> deletedRules = switchManager.deleteRulesByCriteria(dpid, false, null, criteria); final OFFlowMod actual = capture.getValue(); assertEquals(OFFlowModCommand.DELETE, actual.getCommand()); assertEquals(testInPort, actual.getMatch().get(MatchField.IN_PORT).getPortNumber()); assertEquals(testInVlan, actual.getMatch().get(MatchField.TUNNEL_ID).getValue()); assertEquals("any", actual.getOutPort().toString()); assertEquals(0, actual.getInstructions().size()); assertEquals(0L, actual.getCookie().getValue()); assertEquals(0L, actual.getCookieMask().getValue()); assertThat(deletedRules, containsInAnyOrder(cookie)); }
|
@Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldDeleteRuleByPriority() throws Exception { final int testPriority = 999; expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL); expect(iofSwitch.write(capture(capture))).andReturn(true).times(3); mockBarrierRequest(); mockFlowStatsRequest(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); expectLastCall(); replay(ofSwitchService, iofSwitch); DeleteRulesCriteria criteria = DeleteRulesCriteria.builder().priority(testPriority).build(); List<Long> deletedRules = switchManager.deleteRulesByCriteria(dpid, false, null, criteria); final OFFlowMod actual = capture.getValue(); assertEquals(OFFlowModCommand.DELETE, actual.getCommand()); assertNull(actual.getMatch().get(MatchField.IN_PORT)); assertNull(actual.getMatch().get(MatchField.VLAN_VID)); assertEquals("any", actual.getOutPort().toString()); assertEquals(0, actual.getInstructions().size()); assertEquals(0L, actual.getCookie().getValue()); assertEquals(0L, actual.getCookieMask().getValue()); assertEquals(testPriority, actual.getPriority()); assertThat(deletedRules, containsInAnyOrder(cookie)); }
|
@Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldDeleteRuleByInPortVlanAndPriority() throws Exception { final int testInPort = 11; final short testInVlan = 101; final int testPriority = 999; expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL); expect(iofSwitch.write(capture(capture))).andReturn(true).times(3); mockBarrierRequest(); mockFlowStatsRequest(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); expectLastCall(); replay(ofSwitchService, iofSwitch); DeleteRulesCriteria criteria = DeleteRulesCriteria.builder() .inPort(testInPort) .encapsulationId((int) testInVlan) .priority(testPriority) .encapsulationType(FlowEncapsulationType.TRANSIT_VLAN) .egressSwitchId(SWITCH_ID) .build(); List<Long> deletedRules = switchManager.deleteRulesByCriteria(dpid, false, null, criteria); final OFFlowMod actual = capture.getValue(); assertEquals(OFFlowModCommand.DELETE, actual.getCommand()); assertEquals(testInPort, actual.getMatch().get(MatchField.IN_PORT).getPortNumber()); assertEquals(testInVlan, actual.getMatch().get(MatchField.VLAN_VID).getVlan()); assertEquals("any", actual.getOutPort().toString()); assertEquals(0, actual.getInstructions().size()); assertEquals(0L, actual.getCookie().getValue()); assertEquals(0L, actual.getCookieMask().getValue()); assertEquals(testPriority, actual.getPriority()); assertThat(deletedRules, containsInAnyOrder(cookie)); }
|
@Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldDeleteRuleByOutPort() throws Exception { final int testOutPort = 21; expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL); expect(iofSwitch.write(capture(capture))).andReturn(true).times(3); mockBarrierRequest(); mockFlowStatsRequest(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); expectLastCall(); replay(ofSwitchService, iofSwitch); DeleteRulesCriteria criteria = DeleteRulesCriteria.builder().outPort(testOutPort).build(); List<Long> deletedRules = switchManager.deleteRulesByCriteria(dpid, false, null, criteria); final OFFlowMod actual = capture.getValue(); assertEquals(OFFlowModCommand.DELETE, actual.getCommand()); assertNull(actual.getMatch().get(MatchField.IN_PORT)); assertNull(actual.getMatch().get(MatchField.VLAN_VID)); assertEquals(testOutPort, actual.getOutPort().getPortNumber()); assertEquals(0L, actual.getCookie().getValue()); assertEquals(0L, actual.getCookieMask().getValue()); assertThat(deletedRules, containsInAnyOrder(cookie)); }
|
@Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = sw.getOFFactory(); for (DeleteRulesCriteria criteriaEntry : criteria) { OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType); logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid); pushFlow(sw, "--DeleteFlow--", dropFlowDelete); } sendBarrierRequest(sw); List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid); Set<Long> cookiesAfter = flowStatsAfter.stream() .map(entry -> entry.getCookie().getValue()) .collect(Collectors.toSet()); return flowStatsBefore.stream() .map(entry -> entry.getCookie().getValue()) .filter(cookie -> !cookiesAfter.contains(cookie)) .peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)) .collect(toList()); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldInstallMeterWithKbpsFlag() throws Exception { expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription); expect(iofSwitch.getId()).andStubReturn(dpid); expect(switchDescription.getManufacturerDescription()).andStubReturn("Centec Inc."); expect(featureDetectorService.detectSwitch(iofSwitch)).andStubReturn(Sets.newHashSet(METERS)); mockGetMetersRequest(Collections.emptyList(), true, 0); mockBarrierRequest(); Capture<OFMeterMod> capture = EasyMock.newCapture(CaptureType.ALL); expect(iofSwitch.write(capture(capture))).andReturn(true).times(1); replay(ofSwitchService, iofSwitch, switchDescription, featureDetectorService); long rate = 100L; long burstSize = 1000L; Set<OFMeterFlags> flags = ImmutableSet.of(OFMeterFlags.KBPS, OFMeterFlags.STATS, OFMeterFlags.BURST); OFMeterMod ofMeterMod = buildMeterMod(iofSwitch.getOFFactory(), rate, burstSize, unicastMeterId, flags); switchManager.processMeter(iofSwitch, ofMeterMod); final List<OFMeterMod> actual = capture.getValues(); assertEquals(1, actual.size()); assertThat(actual, everyItem(hasProperty("command", equalTo(OFMeterModCommand.ADD)))); assertThat(actual, everyItem(hasProperty("meterId", equalTo(unicastMeterId)))); assertThat(actual, everyItem(hasProperty("flags", containsInAnyOrder(flags.toArray())))); for (OFMeterMod mod : actual) { assertThat(mod.getMeters(), everyItem(hasProperty("rate", is(rate)))); assertThat(mod.getMeters(), everyItem(hasProperty("burstSize", is(burstSize)))); } }
|
@VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldReinstallMeterIfFlagIsIncorrect() throws Exception { long expectedRate = config.getUnicastRateLimit(); expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription); expect(iofSwitch.getId()).andStubReturn(dpid); expect(switchDescription.getManufacturerDescription()).andStubReturn("Centec Inc."); expect(featureDetectorService.detectSwitch(iofSwitch)).andStubReturn(Sets.newHashSet(METERS)); mockBarrierRequest(); mockGetMetersRequest(Lists.newArrayList(unicastMeterId), false, expectedRate); Capture<OFMeterMod> capture = EasyMock.newCapture(CaptureType.ALL); expect(iofSwitch.write(capture(capture))).andReturn(true).times(2); replay(ofSwitchService, iofSwitch, switchDescription, featureDetectorService); Set<OFMeterFlags> flags = ImmutableSet.of(OFMeterFlags.KBPS, OFMeterFlags.STATS, OFMeterFlags.BURST); OFMeterMod ofMeterMod = buildMeterMod(iofSwitch.getOFFactory(), expectedRate, config.getSystemMeterBurstSizeInPackets(), unicastMeterId, flags); switchManager.processMeter(iofSwitch, ofMeterMod); final List<OFMeterMod> actual = capture.getValues(); assertEquals(2, actual.size()); assertThat(actual.get(0), hasProperty("command", equalTo(OFMeterModCommand.DELETE))); assertThat(actual.get(1), hasProperty("command", equalTo(OFMeterModCommand.ADD))); assertThat(actual.get(1), hasProperty("meterId", equalTo(unicastMeterId))); assertThat(actual.get(1), hasProperty("flags", containsInAnyOrder(flags.toArray()))); }
|
@VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldRenstallMetersIfRateIsUpdated() throws Exception { long unicastMeter = createMeterIdForDefaultRule(VERIFICATION_UNICAST_RULE_COOKIE).getValue(); long originRate = config.getBroadcastRateLimit(); long updatedRate = config.getBroadcastRateLimit() + 10; expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription); expect(iofSwitch.getId()).andStubReturn(dpid); expect(switchDescription.getManufacturerDescription()).andStubReturn(StringUtils.EMPTY); expect(featureDetectorService.detectSwitch(iofSwitch)).andStubReturn(Sets.newHashSet(PKTPS_FLAG)); Capture<OFMeterMod> capture = EasyMock.newCapture(CaptureType.ALL); expect(iofSwitch.write(capture(capture))).andReturn(true).times(2); mockBarrierRequest(); mockGetMetersRequest(Lists.newArrayList(unicastMeter), true, originRate); replay(ofSwitchService, iofSwitch, switchDescription, featureDetectorService); Set<OFMeterFlags> flags = ImmutableSet.of(OFMeterFlags.PKTPS, OFMeterFlags.STATS, OFMeterFlags.BURST); OFMeterMod ofMeterMod = buildMeterMod(iofSwitch.getOFFactory(), updatedRate, config.getSystemMeterBurstSizeInPackets(), unicastMeter, flags); switchManager.processMeter(iofSwitch, ofMeterMod); final List<OFMeterMod> actual = capture.getValues(); assertEquals(2, actual.size()); assertThat(actual.get(0), hasProperty("command", equalTo(OFMeterModCommand.DELETE))); assertThat(actual.get(1), hasProperty("command", equalTo(OFMeterModCommand.ADD))); assertThat(actual.get(1), hasProperty("meterId", equalTo(unicastMeter))); assertThat(actual.get(1), hasProperty("flags", containsInAnyOrder(flags.toArray()))); }
|
@VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationException e) { logger.warn("Meter {} won't be installed on the switch {}: {}", meterId, sw.getId(), e.getMessage()); return; } OFMeterBandDrop meterBandDrop = Optional.ofNullable(meterConfig) .map(OFMeterConfig::getEntries) .flatMap(entries -> entries.stream().findFirst()) .map(OFMeterBandDrop.class::cast) .orElse(null); try { OFMeterBandDrop ofMeterBandDrop = sw.getOFFactory().getVersion().compareTo(OF_13) > 0 ? (OFMeterBandDrop) meterMod.getBands().get(0) : (OFMeterBandDrop) meterMod.getMeters().get(0); long rate = ofMeterBandDrop.getRate(); Set<OFMeterFlags> flags = meterMod.getFlags(); if (meterBandDrop != null && meterBandDrop.getRate() == rate && CollectionUtils.isEqualCollection(meterConfig.getFlags(), flags)) { logger.debug("Meter {} won't be reinstalled on switch {}. It already exists", meterId, sw.getId()); return; } if (meterBandDrop != null) { logger.info("Meter {} with origin rate {} will be reinstalled on {} switch.", meterId, sw.getId(), meterBandDrop.getRate()); buildAndDeleteMeter(sw, sw.getId(), meterId); sendBarrierRequest(sw); } installMeterMod(sw, meterMod); } catch (SwitchOperationException e) { logger.warn("Failed to (re)install meter {} on switch {}: {}", meterId, sw.getId(), e.getMessage()); } } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldNotInstallMetersIfAlreadyExists() throws Exception { long expectedRate = config.getBroadcastRateLimit(); expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription); expect(iofSwitch.getId()).andStubReturn(dpid); expect(switchDescription.getManufacturerDescription()).andStubReturn(StringUtils.EMPTY); expect(switchDescription.getSoftwareDescription()).andStubReturn(StringUtils.EMPTY); Capture<OFFlowMod> capture = EasyMock.newCapture(); expect(iofSwitch.write(capture(capture))).andStubReturn(true); expect(featureDetectorService.detectSwitch(iofSwitch)) .andReturn(Sets.newHashSet(GROUP_PACKET_OUT_CONTROLLER, NOVIFLOW_COPY_FIELD, PKTPS_FLAG)) .times(8); mockBarrierRequest(); mockGetMetersRequest(Lists.newArrayList(unicastMeterId, broadcastMeterId), true, expectedRate); mockGetGroupsRequest(Lists.newArrayList(ROUND_TRIP_LATENCY_GROUP_ID)); replay(ofSwitchService, iofSwitch, switchDescription, featureDetectorService); switchManager.installDefaultRules(iofSwitch.getId()); }
|
@Override public List<Long> installDefaultRules(final DatapathId dpid) throws SwitchOperationException { List<Long> rules = new ArrayList<>(); rules.add(installDropFlow(dpid)); rules.add(installVerificationRule(dpid, true)); rules.add(installVerificationRule(dpid, false)); rules.add(installDropLoopRule(dpid)); rules.add(installBfdCatchFlow(dpid)); rules.add(installRoundTripLatencyFlow(dpid)); rules.add(installUnicastVerificationRuleVxlan(dpid)); return rules; }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> installDefaultRules(final DatapathId dpid) throws SwitchOperationException { List<Long> rules = new ArrayList<>(); rules.add(installDropFlow(dpid)); rules.add(installVerificationRule(dpid, true)); rules.add(installVerificationRule(dpid, false)); rules.add(installDropLoopRule(dpid)); rules.add(installBfdCatchFlow(dpid)); rules.add(installRoundTripLatencyFlow(dpid)); rules.add(installUnicastVerificationRuleVxlan(dpid)); return rules; } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> installDefaultRules(final DatapathId dpid) throws SwitchOperationException { List<Long> rules = new ArrayList<>(); rules.add(installDropFlow(dpid)); rules.add(installVerificationRule(dpid, true)); rules.add(installVerificationRule(dpid, false)); rules.add(installDropLoopRule(dpid)); rules.add(installBfdCatchFlow(dpid)); rules.add(installRoundTripLatencyFlow(dpid)); rules.add(installUnicastVerificationRuleVxlan(dpid)); return rules; } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> installDefaultRules(final DatapathId dpid) throws SwitchOperationException { List<Long> rules = new ArrayList<>(); rules.add(installDropFlow(dpid)); rules.add(installVerificationRule(dpid, true)); rules.add(installVerificationRule(dpid, false)); rules.add(installDropLoopRule(dpid)); rules.add(installBfdCatchFlow(dpid)); rules.add(installRoundTripLatencyFlow(dpid)); rules.add(installUnicastVerificationRuleVxlan(dpid)); return rules; } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> installDefaultRules(final DatapathId dpid) throws SwitchOperationException { List<Long> rules = new ArrayList<>(); rules.add(installDropFlow(dpid)); rules.add(installVerificationRule(dpid, true)); rules.add(installVerificationRule(dpid, false)); rules.add(installDropLoopRule(dpid)); rules.add(installBfdCatchFlow(dpid)); rules.add(installRoundTripLatencyFlow(dpid)); rules.add(installUnicastVerificationRuleVxlan(dpid)); return rules; } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void shouldPrepareFlowUpdateResultShouldNotUpdateFirstCase() { String flowId = "test_flow_id"; FlowPatch flowDto = FlowPatch.builder() .flowId(flowId) .maxLatency(100L) .pathComputationStrategy(PathComputationStrategy.MAX_LATENCY) .build(); Flow flow = Flow.builder() .flowId(flowId) .srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()) .destSwitch(Switch.builder().switchId(new SwitchId(2)).build()) .maxLatency(100L) .pathComputationStrategy(PathComputationStrategy.MAX_LATENCY) .build(); UpdateFlowResult result = flowOperationsService.prepareFlowUpdateResult(flowDto, flow).build(); assertFalse(result.isNeedUpdateFlow()); }
|
@VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
@Test public void validateRoundTripLatencyGroup() { OFGroupAdd groupAdd = getOfGroupAddInstruction(); assertTrue(runValidateRoundTripLatencyGroup(groupAdd.getBuckets())); }
|
@VisibleForTesting boolean validateRoundTripLatencyGroup(DatapathId dpId, OFGroupDescStatsEntry groupDesc) { return groupDesc.getBuckets().size() == 2 && validateRoundTripSendToControllerBucket(dpId, groupDesc.getBuckets().get(0)) && validateRoundTripSendBackBucket(groupDesc.getBuckets().get(1)); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting boolean validateRoundTripLatencyGroup(DatapathId dpId, OFGroupDescStatsEntry groupDesc) { return groupDesc.getBuckets().size() == 2 && validateRoundTripSendToControllerBucket(dpId, groupDesc.getBuckets().get(0)) && validateRoundTripSendBackBucket(groupDesc.getBuckets().get(1)); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting boolean validateRoundTripLatencyGroup(DatapathId dpId, OFGroupDescStatsEntry groupDesc) { return groupDesc.getBuckets().size() == 2 && validateRoundTripSendToControllerBucket(dpId, groupDesc.getBuckets().get(0)) && validateRoundTripSendBackBucket(groupDesc.getBuckets().get(1)); } }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting boolean validateRoundTripLatencyGroup(DatapathId dpId, OFGroupDescStatsEntry groupDesc) { return groupDesc.getBuckets().size() == 2 && validateRoundTripSendToControllerBucket(dpId, groupDesc.getBuckets().get(0)) && validateRoundTripSendBackBucket(groupDesc.getBuckets().get(1)); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); }
|
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting boolean validateRoundTripLatencyGroup(DatapathId dpId, OFGroupDescStatsEntry groupDesc) { return groupDesc.getBuckets().size() == 2 && validateRoundTripSendToControllerBucket(dpId, groupDesc.getBuckets().get(0)) && validateRoundTripSendBackBucket(groupDesc.getBuckets().get(1)); } @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override @NewCorrelationContextRequired Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override String getName(); @Override void activate(DatapathId dpid); @Override void deactivate(DatapathId dpid); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode); @Override List<Long> installDefaultRules(final DatapathId dpid); @Override long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort,
int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType,
long meterId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installServer42IngressFlow(
DatapathId dpid, DatapathId dstDpid, Long cookie, org.openkilda.model.MacAddress server42MacAddress,
int server42Port, int outputPort, int customerPort, int inputVlanId, int transitTunnelId,
OutputVlanType outputVlanType, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType,
FlowEncapsulationType encapsulationType,
boolean multiTable); @Override long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable); @Override long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort,
int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId,
boolean multiTable); @Override void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie); @Override List<OFFlowMod> getExpectedDefaultFlows(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<MeterEntry> getExpectedDefaultMeters(DatapathId dpid, boolean multiTable, boolean switchLldp,
boolean switchArp); @Override List<OFFlowMod> getExpectedIslFlowsForPort(DatapathId dpid, int port); @Override List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid); @Override List<OFMeterConfig> dumpMeters(final DatapathId dpid); @Override OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId); @Override void installMeterForFlow(DatapathId dpid, long bandwidth, final long meterId); @Override void modifyMeterForFlow(DatapathId dpid, long meterId, long bandwidth); @Override Map<DatapathId, IOFSwitch> getAllSwitchMap(boolean visible); @Override void deleteMeter(final DatapathId dpid, final long meterId); @Override List<Long> deleteAllNonDefaultRules(final DatapathId dpid); @Override List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType,
DeleteRulesCriteria... criteria); @Override List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts,
List<Integer> flowPorts, Set<Integer> flowLldpPorts,
Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts,
boolean multiTable, boolean switchLldp, boolean switchArp,
boolean server42FlowRtt); @Override Long installUnicastVerificationRuleVxlan(final DatapathId dpid); @Override Long installVerificationRule(final DatapathId dpid, final boolean isBroadcast); @Override List<OFGroupDescStatsEntry> dumpGroups(DatapathId dpid); @Override void installDropFlowCustom(final DatapathId dpid, String dstMac, String dstMask,
final long cookie, final int priority); @Override Long installDropFlow(final DatapathId dpid); @Override Long installDropFlowForTable(final DatapathId dpid, final int tableId,
final long cookie); @Override Long installBfdCatchFlow(DatapathId dpid); @Override Long installRoundTripLatencyFlow(DatapathId dpid); @Override long installEgressIslVxlanRule(DatapathId dpid, int port); @Override long removeEgressIslVxlanRule(DatapathId dpid, int port); @Override long installTransitIslVxlanRule(DatapathId dpid, int port); @Override long removeTransitIslVxlanRule(DatapathId dpid, int port); @Override long installEgressIslVlanRule(DatapathId dpid, int port); Long installLldpTransitFlow(DatapathId dpid); @Override Long installLldpInputPreDropFlow(DatapathId dpid); @Override Long installArpTransitFlow(DatapathId dpid); @Override Long installArpInputPreDropFlow(DatapathId dpid); @Override Long installServer42InputFlow(DatapathId dpid, int server42Port, int customerPort,
org.openkilda.model.MacAddress server42macAddress); @Override Long installServer42TurningFlow(DatapathId dpid); @Override Long installServer42OutputVlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override Long installServer42OutputVxlanFlow(
DatapathId dpid, int port, int vlan, org.openkilda.model.MacAddress macAddress); @Override long removeEgressIslVlanRule(DatapathId dpid, int port); @Override long installIntermediateIngressRule(DatapathId dpid, int port); @Override long removeIntermediateIngressRule(DatapathId dpid, int port); @Override long removeLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeArpInputCustomerFlow(DatapathId dpid, int port); @Override Long removeServer42InputFlow(DatapathId dpid, int port); @Override OFFlowMod buildIntermediateIngressRule(DatapathId dpid, int port); @Override long installLldpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port); @Override Long installLldpIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressFlow(DatapathId dpid); @Override Long installLldpPostIngressVxlanFlow(DatapathId dpid); @Override Long installLldpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installArpInputCustomerFlow(DatapathId dpid, int port); @Override OFFlowMod buildArpInputCustomerFlow(DatapathId dpid, int port); @Override List<OFFlowMod> buildExpectedServer42Flows(
DatapathId dpid, int server42Port, int server42Vlan, org.openkilda.model.MacAddress server42MacAddress,
Set<Integer> customerPorts); @Override Long installArpIngressFlow(DatapathId dpid); @Override Long installArpPostIngressFlow(DatapathId dpid); @Override Long installArpPostIngressVxlanFlow(DatapathId dpid); @Override Long installArpPostIngressOneSwitchFlow(DatapathId dpid); @Override Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid); @Override Long installEgressTablePassThroughDefaultRule(DatapathId dpid); @Override List<Long> installMultitableEndpointIslRules(DatapathId dpid, int port); @Override List<Long> removeMultitableEndpointIslRules(DatapathId dpid, int port); @Override Long installDropLoopRule(DatapathId dpid); @Override IOFSwitch lookupSwitch(DatapathId dpId); @Override InetAddress getSwitchIpAddress(IOFSwitch sw); @Override List<OFPortDesc> getEnabledPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(DatapathId dpId); @Override List<OFPortDesc> getPhysicalPorts(IOFSwitch sw); @Override void safeModeTick(); @Override void configurePort(DatapathId dpId, int portNumber, Boolean portAdminDown); @Override List<OFPortDesc> dumpPortsDescription(DatapathId dpid); @Override SwitchManagerConfig getSwitchManagerConfig(); static final long FLOW_COOKIE_MASK; static final int VERIFICATION_RULE_PRIORITY; static final int VERIFICATION_RULE_VXLAN_PRIORITY; static final int DROP_VERIFICATION_LOOP_RULE_PRIORITY; static final int CATCH_BFD_RULE_PRIORITY; static final int ROUND_TRIP_LATENCY_RULE_PRIORITY; static final int FLOW_PRIORITY; static final int ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE; static final int ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE; static final int INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE; static final int ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE; static final int DEFAULT_FLOW_PRIORITY; static final int MINIMAL_POSITIVE_PRIORITY; static final int SERVER_42_INPUT_PRIORITY; static final int SERVER_42_TURNING_PRIORITY; static final int SERVER_42_OUTPUT_VLAN_PRIORITY; static final int SERVER_42_OUTPUT_VXLAN_PRIORITY; static final int LLDP_INPUT_PRE_DROP_PRIORITY; static final int LLDP_TRANSIT_ISL_PRIORITY; static final int LLDP_INPUT_CUSTOMER_PRIORITY; static final int LLDP_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_PRIORITY; static final int LLDP_POST_INGRESS_VXLAN_PRIORITY; static final int LLDP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int ARP_INPUT_PRE_DROP_PRIORITY; static final int ARP_TRANSIT_ISL_PRIORITY; static final int ARP_INPUT_CUSTOMER_PRIORITY; static final int ARP_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_PRIORITY; static final int ARP_POST_INGRESS_VXLAN_PRIORITY; static final int ARP_POST_INGRESS_ONE_SWITCH_PRIORITY; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY_OFFSET; static final int SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY; static final int BDF_DEFAULT_PORT; static final int ROUND_TRIP_LATENCY_GROUP_ID; static final MacAddress STUB_VXLAN_ETH_DST_MAC; static final IPv4Address STUB_VXLAN_IPV4_SRC; static final IPv4Address STUB_VXLAN_IPV4_DST; static final int STUB_VXLAN_UDP_SRC; static final int ARP_VXLAN_UDP_SRC; static final int SERVER_42_FORWARD_UDP_PORT; static final int SERVER_42_REVERSE_UDP_PORT; static final int VXLAN_UDP_DST; static final int ETH_SRC_OFFSET; static final int INTERNAL_ETH_SRC_OFFSET; static final int MAC_ADDRESS_SIZE_IN_BITS; static final int TABLE_1; static final int INPUT_TABLE_ID; static final int PRE_INGRESS_TABLE_ID; static final int INGRESS_TABLE_ID; static final int POST_INGRESS_TABLE_ID; static final int EGRESS_TABLE_ID; static final int TRANSIT_TABLE_ID; static final int NOVIFLOW_TIMESTAMP_SIZE_IN_BITS; }
|
@Test public void sendStatsTest() throws Exception { Builder bucketBuilder = FlowLatencyPacketBucket.newBuilder(); FlowLatencyPacket packet1 = FlowLatencyPacket.newBuilder() .setFlowId("some-flow-id-1") .setDirection(false) .setT0(100) .setT1(150) .setPacketId(1).build(); FlowLatencyPacket packet2 = FlowLatencyPacket.newBuilder() .setDirection(true) .setT0(200) .setT1(250) .setPacketId(2).build(); bucketBuilder.addPacket(packet1); bucketBuilder.addPacket(packet2); statsCollector.sendStats(bucketBuilder.build()); ArgumentCaptor<InfoMessage> argument = ArgumentCaptor.forClass(InfoMessage.class); verify(template).send(eq(toStorm), eq(packet1.getFlowId()), argument.capture()); InfoMessage packet1Message = argument.getValue(); FlowRttStatsData statsPacket1 = (FlowRttStatsData) packet1Message.getData(); assertThat(statsPacket1).extracting( FlowRttStatsData::getFlowId, FlowRttStatsData::getT0, FlowRttStatsData::getT1) .contains(packet1.getFlowId(), packet1.getT0(), packet1.getT1()); assertThat(statsPacket1) .extracting(FlowRttStatsData::getDirection) .isEqualTo("forward"); verify(template).send(eq(toStorm), eq(packet2.getFlowId()), argument.capture()); InfoMessage packet2Message = argument.getValue(); FlowRttStatsData statsPacket2 = (FlowRttStatsData) packet2Message.getData(); assertThat(statsPacket2).extracting( FlowRttStatsData::getFlowId, FlowRttStatsData::getT0, FlowRttStatsData::getT1) .contains(packet2.getFlowId(), packet2.getT0(), packet2.getT1()); assertThat(statsPacket2) .extracting(FlowRttStatsData::getDirection) .isEqualTo("reverse"); }
|
void sendStats(FlowLatencyPacketBucket flowLatencyPacketBucket) throws InvalidProtocolBufferException { long currentTimeMillis = System.currentTimeMillis(); for (FlowLatencyPacket packet : flowLatencyPacketBucket.getPacketList()) { FlowRttStatsData data = new FlowRttStatsData( packet.getFlowId(), FlowDirection.fromBoolean(packet.getDirection()).name().toLowerCase(), packet.getT0(), packet.getT1() ); InfoMessage message = new InfoMessage(data, currentTimeMillis, String.format("stats42-%s-%d", sessionId, packet.getPacketId())); log.debug("InfoMessage {}", message); template.send(toStorm, packet.getFlowId(), message); } }
|
StatsCollector extends Thread { void sendStats(FlowLatencyPacketBucket flowLatencyPacketBucket) throws InvalidProtocolBufferException { long currentTimeMillis = System.currentTimeMillis(); for (FlowLatencyPacket packet : flowLatencyPacketBucket.getPacketList()) { FlowRttStatsData data = new FlowRttStatsData( packet.getFlowId(), FlowDirection.fromBoolean(packet.getDirection()).name().toLowerCase(), packet.getT0(), packet.getT1() ); InfoMessage message = new InfoMessage(data, currentTimeMillis, String.format("stats42-%s-%d", sessionId, packet.getPacketId())); log.debug("InfoMessage {}", message); template.send(toStorm, packet.getFlowId(), message); } } }
|
StatsCollector extends Thread { void sendStats(FlowLatencyPacketBucket flowLatencyPacketBucket) throws InvalidProtocolBufferException { long currentTimeMillis = System.currentTimeMillis(); for (FlowLatencyPacket packet : flowLatencyPacketBucket.getPacketList()) { FlowRttStatsData data = new FlowRttStatsData( packet.getFlowId(), FlowDirection.fromBoolean(packet.getDirection()).name().toLowerCase(), packet.getT0(), packet.getT1() ); InfoMessage message = new InfoMessage(data, currentTimeMillis, String.format("stats42-%s-%d", sessionId, packet.getPacketId())); log.debug("InfoMessage {}", message); template.send(toStorm, packet.getFlowId(), message); } } StatsCollector(KafkaTemplate<String, Object> template); }
|
StatsCollector extends Thread { void sendStats(FlowLatencyPacketBucket flowLatencyPacketBucket) throws InvalidProtocolBufferException { long currentTimeMillis = System.currentTimeMillis(); for (FlowLatencyPacket packet : flowLatencyPacketBucket.getPacketList()) { FlowRttStatsData data = new FlowRttStatsData( packet.getFlowId(), FlowDirection.fromBoolean(packet.getDirection()).name().toLowerCase(), packet.getT0(), packet.getT1() ); InfoMessage message = new InfoMessage(data, currentTimeMillis, String.format("stats42-%s-%d", sessionId, packet.getPacketId())); log.debug("InfoMessage {}", message); template.send(toStorm, packet.getFlowId(), message); } } StatsCollector(KafkaTemplate<String, Object> template); @Override void run(); }
|
StatsCollector extends Thread { void sendStats(FlowLatencyPacketBucket flowLatencyPacketBucket) throws InvalidProtocolBufferException { long currentTimeMillis = System.currentTimeMillis(); for (FlowLatencyPacket packet : flowLatencyPacketBucket.getPacketList()) { FlowRttStatsData data = new FlowRttStatsData( packet.getFlowId(), FlowDirection.fromBoolean(packet.getDirection()).name().toLowerCase(), packet.getT0(), packet.getT1() ); InfoMessage message = new InfoMessage(data, currentTimeMillis, String.format("stats42-%s-%d", sessionId, packet.getPacketId())); log.debug("InfoMessage {}", message); template.send(toStorm, packet.getFlowId(), message); } } StatsCollector(KafkaTemplate<String, Object> template); @Override void run(); }
|
@Test public void addFlow() throws Exception { AddFlow addFlow = AddFlow.builder() .flowId("some-flow-id") .encapsulationType(EncapsulationType.VLAN) .tunnelId(1001L) .direction(FlowDirection.REVERSE) .port(42) .build(); String switchId = "00:00:1b:45:18:d6:71:5a"; gate.listen(addFlow, switchId); CommandPacket commandPacket = getCommandPacket(); assertThat(commandPacket.getType()).isEqualTo(Type.ADD_FLOW); assertThat(commandPacket.getCommandCount()).isEqualTo(1); Any command = commandPacket.getCommand(0); assertThat(command.is(Control.AddFlow.class)).isTrue(); Control.AddFlow unpack = command.unpack(Control.AddFlow.class); Flow flow = unpack.getFlow(); assertThat(flow.getFlowId()).isEqualTo(addFlow.getFlowId()); assertThat(flow.getEncapsulationType().name()).isEqualTo(addFlow.getEncapsulationType().name()); assertThat(flow.getTunnelId()).isEqualTo(addFlow.getTunnelId()); assertThat(flow.getDirection()).isEqualTo(FlowDirection.toBoolean(addFlow.getDirection())); assertThat(flow.getUdpSrcPort()).isEqualTo(udpSrcPortOffset + addFlow.getPort()); assertThat(flow.getTransitEncapsulationType()).isEqualTo(Flow.EncapsulationType.VLAN); Map<Long, List<String>> vlanToSwitch = switchToVlanMapping.getVlan(); vlanToSwitch.forEach((vlan, switches) -> { if (switches.contains(switchId)) { assertThat(flow.getTransitTunnelId()).isEqualTo(vlan); } }); assertThat(flow.getDstMac()).isSubstringOf(switchId).isNotEqualTo(switchId); }
|
@KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
@Test public void removeFlow() throws Exception { RemoveFlow removeFlow = RemoveFlow.builder() .flowId("some-flow-id") .build(); gate.listen(removeFlow); CommandPacket commandPacket = getCommandPacket(); assertThat(commandPacket.getType()).isEqualTo(Type.REMOVE_FLOW); assertThat(commandPacket.getCommandList()).hasSize(1); Any command = commandPacket.getCommand(0); assertThat(command.is(Control.RemoveFlow.class)).isTrue(); Control.RemoveFlow unpack = command.unpack(Control.RemoveFlow.class); assertThat(unpack.getFlow().getFlowId()).isEqualTo(removeFlow.getFlowId()); }
|
@KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
@Test public void clearFlowsTest() throws Exception { Headers headers = Headers.builder().correlationId("some-correlation-id").build(); ClearFlows clearFlows = ClearFlows.builder().headers(headers).build(); gate.listen(clearFlows); CommandPacket commandPacket = getCommandPacket(); assertThat(commandPacket.getType()).isEqualTo(Type.CLEAR_FLOWS); assertThat(commandPacket.getCommandList()).isEmpty(); }
|
@KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
@Test public void listFlowsTest() throws Exception { Builder commandPacketResponseBuilded = CommandPacketResponse.newBuilder(); Flow flow1 = Flow.newBuilder().setFlowId("some-flow-id-01").build(); Flow flow2 = Flow.newBuilder().setFlowId("some-flow-id-02").build(); commandPacketResponseBuilded.addResponse(Any.pack(flow1)); commandPacketResponseBuilded.addResponse(Any.pack(flow2)); CommandPacketResponse commandPacketResponse = commandPacketResponseBuilded.build(); when(zeroMqClient.send(argThat( commandPacket -> commandPacket.getType() == Type.LIST_FLOWS))) .thenReturn(commandPacketResponse); Headers headers = Headers.builder().correlationId("some-correlation-id").build(); gate.listen(new ListFlowsRequest(headers)); ArgumentCaptor<ListFlowsResponse> argument = ArgumentCaptor.forClass(ListFlowsResponse.class); verify(template).send(eq(toStorm), argument.capture()); ListFlowsResponse response = argument.getValue(); assertThat(response.getFlowIds()).contains(flow1.getFlowId(), flow2.getFlowId()); }
|
@KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
@Test public void pushSettingsTest() throws Exception { PushSettings data = PushSettings.builder() .packetGenerationIntervalInMs(500) .build(); gate.listen(data); CommandPacket commandPacket = getCommandPacket(); assertThat(commandPacket.getType()).isEqualTo(Type.PUSH_SETTINGS); assertThat(commandPacket.getCommandList()).hasSize(1); Any command = commandPacket.getCommand(0); assertThat(command.is(Control.PushSettings.class)).isTrue(); Control.PushSettings unpack = command.unpack(Control.PushSettings.class); assertThat(unpack.getPacketGenerationIntervalInMs()).isEqualTo(500); }
|
@KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumber(data.getEncapsulationType().ordinal())) .setTunnelId(data.getTunnelId()) .setTransitEncapsulationType(EncapsulationType.VLAN) .setTransitTunnelId(switchToVlanMap.get(switchIdKey)) .setDirection(FlowDirection.toBoolean(data.getDirection())) .setUdpSrcPort(udpSrcPortOffset + data.getPort()) .setDstMac(switchId.toMacAddress()) .build(); Control.AddFlow addFlow = Control.AddFlow.newBuilder().setFlow(flow).build(); builder.setType(Type.ADD_FLOW); builder.addCommand(Any.pack(addFlow)); CommandPacket packet = builder.build(); try { zeroMqClient.send(packet); } catch (InvalidProtocolBufferException e) { log.error("Marshalling error on {}", data); } } Gate(@Autowired KafkaTemplate<String, Object> template,
@Autowired ZeroMqClient zeroMqClient,
@Autowired SwitchToVlanMapping switchToVlanMapping
); }
|
@Test public void addSwitch() throws Exception { speakerBolt.addSwitch(switchMessage); assertEquals(1, speakerBolt.switches.size()); ISwitchImpl sw = speakerBolt.switches.get(dpid); assertTrue(sw.isActive()); List<IPortImpl> ports = sw.getPorts(); assertEquals(numOfPorts, ports.size()); for (IPortImpl port : ports) { if (port.getNumber() != localLinkPort) { assertFalse(port.isActive()); assertFalse(port.isActiveIsl()); } else { assertTrue(port.isActive()); assertTrue(port.isActiveIsl()); } } }
|
protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; }
|
SpeakerBolt extends BaseRichBolt { protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; } }
|
SpeakerBolt extends BaseRichBolt { protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; } }
|
SpeakerBolt extends BaseRichBolt { protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; } ISwitchImpl getSwitch(SwitchId name); void doSimulatorCommand(Tuple tuple); void doCommand(Tuple tuple); @Override void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector); @Override void execute(Tuple tuple); @Override void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer); }
|
SpeakerBolt extends BaseRichBolt { protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; } ISwitchImpl getSwitch(SwitchId name); void doSimulatorCommand(Tuple tuple); void doCommand(Tuple tuple); @Override void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector); @Override void execute(Tuple tuple); @Override void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer); }
|
@Test public void testAddSwitchValues() throws Exception { List<Values> values = speakerBolt.addSwitch(switchMessage); assertEquals(3, values.size()); int count = 0; for (Values value : values) { InfoMessage infoMessage = mapper.readValue((String) value.get(1), InfoMessage.class); if (count < 2) { assertThat(infoMessage.getData(), instanceOf(SwitchInfoData.class)); SwitchInfoData sw = (SwitchInfoData) infoMessage.getData(); assertEquals(dpid, sw.getSwitchId()); } else { assertThat(infoMessage.getData(), instanceOf(PortInfoData.class)); PortInfoData port = (PortInfoData) infoMessage.getData(); assertEquals(dpid, port.getSwitchId()); if (port.getPortNo() == localLinkPort) { assertEquals(PortChangeType.UP, port.getState()); } else { assertEquals(PortChangeType.DOWN, port.getState()); } } count++; } }
|
protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; }
|
SpeakerBolt extends BaseRichBolt { protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; } }
|
SpeakerBolt extends BaseRichBolt { protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; } }
|
SpeakerBolt extends BaseRichBolt { protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; } ISwitchImpl getSwitch(SwitchId name); void doSimulatorCommand(Tuple tuple); void doCommand(Tuple tuple); @Override void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector); @Override void execute(Tuple tuple); @Override void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer); }
|
SpeakerBolt extends BaseRichBolt { protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new SwitchId(sw.getDpid().toString()), sw); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ADDED))); values.add(new Values("INFO", makeSwitchMessage(sw, SwitchChangeType.ACTIVATED))); } return values; } ISwitchImpl getSwitch(SwitchId name); void doSimulatorCommand(Tuple tuple); void doCommand(Tuple tuple); @Override void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector); @Override void execute(Tuple tuple); @Override void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer); }
|
@Test public void modState() throws Exception { sw.modState(SwitchChangeType.ACTIVATED); assertTrue(sw.isActive()); sw.modState(SwitchChangeType.DEACTIVATED); assertFalse(sw.isActive()); }
|
@Override public void modState(SwitchChangeType state) throws SimulatorException { this.state = state; switch (state) { case ADDED: break; case ACTIVATED: activate(); break; case DEACTIVATED: case REMOVED: deactivate(); break; case CHANGED: throw new SimulatorException("Received modState of CHANGED, no idea why"); default: throw new SimulatorException(String.format("Unknown state %s", state)); } }
|
ISwitchImpl implements ISwitch { @Override public void modState(SwitchChangeType state) throws SimulatorException { this.state = state; switch (state) { case ADDED: break; case ACTIVATED: activate(); break; case DEACTIVATED: case REMOVED: deactivate(); break; case CHANGED: throw new SimulatorException("Received modState of CHANGED, no idea why"); default: throw new SimulatorException(String.format("Unknown state %s", state)); } } }
|
ISwitchImpl implements ISwitch { @Override public void modState(SwitchChangeType state) throws SimulatorException { this.state = state; switch (state) { case ADDED: break; case ACTIVATED: activate(); break; case DEACTIVATED: case REMOVED: deactivate(); break; case CHANGED: throw new SimulatorException("Received modState of CHANGED, no idea why"); default: throw new SimulatorException(String.format("Unknown state %s", state)); } } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); }
|
ISwitchImpl implements ISwitch { @Override public void modState(SwitchChangeType state) throws SimulatorException { this.state = state; switch (state) { case ADDED: break; case ACTIVATED: activate(); break; case DEACTIVATED: case REMOVED: deactivate(); break; case CHANGED: throw new SimulatorException("Received modState of CHANGED, no idea why"); default: throw new SimulatorException(String.format("Unknown state %s", state)); } } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
ISwitchImpl implements ISwitch { @Override public void modState(SwitchChangeType state) throws SimulatorException { this.state = state; switch (state) { case ADDED: break; case ACTIVATED: activate(); break; case DEACTIVATED: case REMOVED: deactivate(); break; case CHANGED: throw new SimulatorException("Received modState of CHANGED, no idea why"); default: throw new SimulatorException(String.format("Unknown state %s", state)); } } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
@Test public void shouldPrepareFlowUpdateResultShouldNotUpdateSecondCase() { String flowId = "test_flow_id"; FlowPatch flowDto = FlowPatch.builder() .flowId(flowId) .build(); Flow flow = Flow.builder() .flowId(flowId) .srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()) .destSwitch(Switch.builder().switchId(new SwitchId(2)).build()) .maxLatency(100L) .pathComputationStrategy(PathComputationStrategy.MAX_LATENCY) .build(); UpdateFlowResult result = flowOperationsService.prepareFlowUpdateResult(flowDto, flow).build(); assertFalse(result.isNeedUpdateFlow()); }
|
@VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
@Test public void testSetDpid() { SwitchId newDpid = new SwitchId("01:02:03:04:05:06"); sw.setDpid(newDpid); assertEquals(newDpid.toString(), sw.getDpidAsString()); assertEquals(DatapathId.of(newDpid.toString()), sw.getDpid()); DatapathId dpid = sw.getDpid(); sw.setDpid(dpid); assertEquals(dpid, sw.getDpid()); }
|
@Override public void setDpid(DatapathId dpid) { this.dpid = dpid; }
|
ISwitchImpl implements ISwitch { @Override public void setDpid(DatapathId dpid) { this.dpid = dpid; } }
|
ISwitchImpl implements ISwitch { @Override public void setDpid(DatapathId dpid) { this.dpid = dpid; } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); }
|
ISwitchImpl implements ISwitch { @Override public void setDpid(DatapathId dpid) { this.dpid = dpid; } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
ISwitchImpl implements ISwitch { @Override public void setDpid(DatapathId dpid) { this.dpid = dpid; } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
@Test public void addPort() throws Exception { int portNum = sw.getPorts().size(); IPortImpl port = new IPortImpl(sw, PortStateType.UP, portNum); thrown.expect(SimulatorException.class); thrown.expectMessage("Switch already has reached maxPorts"); sw.addPort(port); }
|
@Override public int addPort(IPortImpl port) throws SimulatorException { if (ports.size() < maxPorts) { ports.add(port); } else { throw new SimulatorException(String.format("Switch already has reached maxPorts of %d" + "", maxPorts)); } return port.getNumber(); }
|
ISwitchImpl implements ISwitch { @Override public int addPort(IPortImpl port) throws SimulatorException { if (ports.size() < maxPorts) { ports.add(port); } else { throw new SimulatorException(String.format("Switch already has reached maxPorts of %d" + "", maxPorts)); } return port.getNumber(); } }
|
ISwitchImpl implements ISwitch { @Override public int addPort(IPortImpl port) throws SimulatorException { if (ports.size() < maxPorts) { ports.add(port); } else { throw new SimulatorException(String.format("Switch already has reached maxPorts of %d" + "", maxPorts)); } return port.getNumber(); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); }
|
ISwitchImpl implements ISwitch { @Override public int addPort(IPortImpl port) throws SimulatorException { if (ports.size() < maxPorts) { ports.add(port); } else { throw new SimulatorException(String.format("Switch already has reached maxPorts of %d" + "", maxPorts)); } return port.getNumber(); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
ISwitchImpl implements ISwitch { @Override public int addPort(IPortImpl port) throws SimulatorException { if (ports.size() < maxPorts) { ports.add(port); } else { throw new SimulatorException(String.format("Switch already has reached maxPorts of %d" + "", maxPorts)); } return port.getNumber(); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
@Test public void getPort() throws Exception { int numOfPorts = sw.getPorts().size(); assertEquals(1, sw.getPort(1).getNumber()); thrown.expect(SimulatorException.class); thrown.expectMessage(String.format("Port %d is not defined on %s", numOfPorts, sw.getDpidAsString())); sw.getPort(numOfPorts); }
|
@Override public IPortImpl getPort(int portNum) throws SimulatorException { try { return ports.get(portNum); } catch (IndexOutOfBoundsException e) { throw new SimulatorException(String.format("Port %d is not defined on %s", portNum, getDpidAsString())); } }
|
ISwitchImpl implements ISwitch { @Override public IPortImpl getPort(int portNum) throws SimulatorException { try { return ports.get(portNum); } catch (IndexOutOfBoundsException e) { throw new SimulatorException(String.format("Port %d is not defined on %s", portNum, getDpidAsString())); } } }
|
ISwitchImpl implements ISwitch { @Override public IPortImpl getPort(int portNum) throws SimulatorException { try { return ports.get(portNum); } catch (IndexOutOfBoundsException e) { throw new SimulatorException(String.format("Port %d is not defined on %s", portNum, getDpidAsString())); } } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); }
|
ISwitchImpl implements ISwitch { @Override public IPortImpl getPort(int portNum) throws SimulatorException { try { return ports.get(portNum); } catch (IndexOutOfBoundsException e) { throw new SimulatorException(String.format("Port %d is not defined on %s", portNum, getDpidAsString())); } } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
ISwitchImpl implements ISwitch { @Override public IPortImpl getPort(int portNum) throws SimulatorException { try { return ports.get(portNum); } catch (IndexOutOfBoundsException e) { throw new SimulatorException(String.format("Port %d is not defined on %s", portNum, getDpidAsString())); } } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
@Test public void getFlow() { }
|
@Override public IFlow getFlow(long cookie) throws SimulatorException { try { return flows.get(cookie); } catch (IndexOutOfBoundsException e) { throw new SimulatorException(String.format("Flow %d could not be found.", cookie)); } }
|
ISwitchImpl implements ISwitch { @Override public IFlow getFlow(long cookie) throws SimulatorException { try { return flows.get(cookie); } catch (IndexOutOfBoundsException e) { throw new SimulatorException(String.format("Flow %d could not be found.", cookie)); } } }
|
ISwitchImpl implements ISwitch { @Override public IFlow getFlow(long cookie) throws SimulatorException { try { return flows.get(cookie); } catch (IndexOutOfBoundsException e) { throw new SimulatorException(String.format("Flow %d could not be found.", cookie)); } } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); }
|
ISwitchImpl implements ISwitch { @Override public IFlow getFlow(long cookie) throws SimulatorException { try { return flows.get(cookie); } catch (IndexOutOfBoundsException e) { throw new SimulatorException(String.format("Flow %d could not be found.", cookie)); } } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
ISwitchImpl implements ISwitch { @Override public IFlow getFlow(long cookie) throws SimulatorException { try { return flows.get(cookie); } catch (IndexOutOfBoundsException e) { throw new SimulatorException(String.format("Flow %d could not be found.", cookie)); } } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
@Test public void addFlow() { }
|
@Override public void addFlow(IFlow flow) throws SimulatorException { if (flows.containsKey(flow.getCookie())) { throw new SimulatorException(String.format("Flow %s already exists.", flow.toString())); } flows.put(flow.getCookie(), flow); }
|
ISwitchImpl implements ISwitch { @Override public void addFlow(IFlow flow) throws SimulatorException { if (flows.containsKey(flow.getCookie())) { throw new SimulatorException(String.format("Flow %s already exists.", flow.toString())); } flows.put(flow.getCookie(), flow); } }
|
ISwitchImpl implements ISwitch { @Override public void addFlow(IFlow flow) throws SimulatorException { if (flows.containsKey(flow.getCookie())) { throw new SimulatorException(String.format("Flow %s already exists.", flow.toString())); } flows.put(flow.getCookie(), flow); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); }
|
ISwitchImpl implements ISwitch { @Override public void addFlow(IFlow flow) throws SimulatorException { if (flows.containsKey(flow.getCookie())) { throw new SimulatorException(String.format("Flow %s already exists.", flow.toString())); } flows.put(flow.getCookie(), flow); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
ISwitchImpl implements ISwitch { @Override public void addFlow(IFlow flow) throws SimulatorException { if (flows.containsKey(flow.getCookie())) { throw new SimulatorException(String.format("Flow %s already exists.", flow.toString())); } flows.put(flow.getCookie(), flow); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
@Test public void modFlow() { }
|
@Override public void modFlow(IFlow flow) throws SimulatorException { delFlow(flow.getCookie()); addFlow(flow); }
|
ISwitchImpl implements ISwitch { @Override public void modFlow(IFlow flow) throws SimulatorException { delFlow(flow.getCookie()); addFlow(flow); } }
|
ISwitchImpl implements ISwitch { @Override public void modFlow(IFlow flow) throws SimulatorException { delFlow(flow.getCookie()); addFlow(flow); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); }
|
ISwitchImpl implements ISwitch { @Override public void modFlow(IFlow flow) throws SimulatorException { delFlow(flow.getCookie()); addFlow(flow); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
ISwitchImpl implements ISwitch { @Override public void modFlow(IFlow flow) throws SimulatorException { delFlow(flow.getCookie()); addFlow(flow); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
@Test public void delFlow() { }
|
@Override public void delFlow(long cookie) { flows.remove(cookie); }
|
ISwitchImpl implements ISwitch { @Override public void delFlow(long cookie) { flows.remove(cookie); } }
|
ISwitchImpl implements ISwitch { @Override public void delFlow(long cookie) { flows.remove(cookie); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); }
|
ISwitchImpl implements ISwitch { @Override public void delFlow(long cookie) { flows.remove(cookie); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
ISwitchImpl implements ISwitch { @Override public void delFlow(long cookie) { flows.remove(cookie); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
@Test public void getPortStats() { }
|
@Override public List<PortStatsEntry> getPortStats() { return null; }
|
ISwitchImpl implements ISwitch { @Override public List<PortStatsEntry> getPortStats() { return null; } }
|
ISwitchImpl implements ISwitch { @Override public List<PortStatsEntry> getPortStats() { return null; } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); }
|
ISwitchImpl implements ISwitch { @Override public List<PortStatsEntry> getPortStats() { return null; } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
ISwitchImpl implements ISwitch { @Override public List<PortStatsEntry> getPortStats() { return null; } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate(); @Override boolean isActive(); @Override int getControlPlaneLatency(); @Override void setControlPlaneLatency(int controlPlaneLatency); @Override DatapathId getDpid(); @Override String getDpidAsString(); @Override void setDpid(DatapathId dpid); @Override void setDpid(SwitchId dpid); @Override List<IPortImpl> getPorts(); @Override IPortImpl getPort(int portNum); @Override int addPort(IPortImpl port); @Override int getMaxPorts(); @Override void setMaxPorts(int maxPorts); @Override Map<Long, IFlow> getFlows(); @Override IFlow getFlow(long cookie); @Override void addFlow(IFlow flow); @Override void modFlow(IFlow flow); @Override void delFlow(long cookie); @Override List<PortStatsEntry> getPortStats(); @Override PortStatsEntry getPortStats(int portNum); }
|
@Test public void isActiveIsl() throws Exception { port.enable(); port.setPeerSwitch("00:00:00:00:00:01"); port.setPeerPortNum(10); assertTrue(port.isActiveIsl()); port.disable(); assertFalse(port.isActiveIsl()); port.enable(); port.block(); assertFalse(port.isActiveIsl()); port.unblock(); assertTrue(port.isActiveIsl()); port.disable(); port.unblock(); assertFalse(port.isActiveIsl()); }
|
@Override public boolean isActiveIsl() { return (peerSwitch != null && peerPortNum >= 0 && isActive && isForwarding); }
|
IPortImpl implements IPort { @Override public boolean isActiveIsl() { return (peerSwitch != null && peerPortNum >= 0 && isActive && isForwarding); } }
|
IPortImpl implements IPort { @Override public boolean isActiveIsl() { return (peerSwitch != null && peerPortNum >= 0 && isActive && isForwarding); } IPortImpl(ISwitchImpl sw, PortStateType state, int portNumber); }
|
IPortImpl implements IPort { @Override public boolean isActiveIsl() { return (peerSwitch != null && peerPortNum >= 0 && isActive && isForwarding); } IPortImpl(ISwitchImpl sw, PortStateType state, int portNumber); InfoMessage makePorChangetMessage(); @Override void enable(); @Override void disable(); @Override void block(); @Override void unblock(); void modPort(PortModMessage message); @Override boolean isActive(); @Override boolean isForwarding(); @Override int getNumber(); @Override void setLatency(int latency); @Override int getLatency(); @Override String getPeerSwitch(); @Override void setPeerSwitch(String peerSwitch); @Override void setPeerPortNum(int peerPortNum); @Override int getPeerPortNum(); @Override void setIsl(DatapathId peerSwitch, int peerPortNum); ISwitchImpl getSw(); void setSw(ISwitchImpl sw); @Override boolean isActiveIsl(); @Override PortStatsEntry getStats(); }
|
IPortImpl implements IPort { @Override public boolean isActiveIsl() { return (peerSwitch != null && peerPortNum >= 0 && isActive && isForwarding); } IPortImpl(ISwitchImpl sw, PortStateType state, int portNumber); InfoMessage makePorChangetMessage(); @Override void enable(); @Override void disable(); @Override void block(); @Override void unblock(); void modPort(PortModMessage message); @Override boolean isActive(); @Override boolean isForwarding(); @Override int getNumber(); @Override void setLatency(int latency); @Override int getLatency(); @Override String getPeerSwitch(); @Override void setPeerSwitch(String peerSwitch); @Override void setPeerPortNum(int peerPortNum); @Override int getPeerPortNum(); @Override void setIsl(DatapathId peerSwitch, int peerPortNum); ISwitchImpl getSw(); void setSw(ISwitchImpl sw); @Override boolean isActiveIsl(); @Override PortStatsEntry getStats(); }
|
@Test public void getStats() throws Exception { }
|
@Override public PortStatsEntry getStats() { if (isForwarding && isActive) { this.rxPackets += rand.nextInt(MAX_LARGE); this.txPackets += rand.nextInt(MAX_LARGE); this.rxBytes += rand.nextInt(MAX_LARGE); this.txBytes += rand.nextInt(MAX_LARGE); this.rxDropped += rand.nextInt(MAX_SMALL); this.txDropped += rand.nextInt(MAX_SMALL); this.rxErrors += rand.nextInt(MAX_SMALL); this.txErrors += rand.nextInt(MAX_SMALL); this.rxFrameErr += rand.nextInt(MAX_SMALL); this.rxOverErr += rand.nextInt(MAX_SMALL); this.rxCrcErr += rand.nextInt(MAX_SMALL); this.collisions += rand.nextInt(MAX_SMALL); } return new PortStatsEntry(this.number, this.rxPackets, this.txPackets, this.rxBytes, this.txBytes, this.rxDropped, this.txDropped, this.rxErrors, this.txErrors, this.rxFrameErr, this.rxOverErr, this.rxCrcErr, this.collisions); }
|
IPortImpl implements IPort { @Override public PortStatsEntry getStats() { if (isForwarding && isActive) { this.rxPackets += rand.nextInt(MAX_LARGE); this.txPackets += rand.nextInt(MAX_LARGE); this.rxBytes += rand.nextInt(MAX_LARGE); this.txBytes += rand.nextInt(MAX_LARGE); this.rxDropped += rand.nextInt(MAX_SMALL); this.txDropped += rand.nextInt(MAX_SMALL); this.rxErrors += rand.nextInt(MAX_SMALL); this.txErrors += rand.nextInt(MAX_SMALL); this.rxFrameErr += rand.nextInt(MAX_SMALL); this.rxOverErr += rand.nextInt(MAX_SMALL); this.rxCrcErr += rand.nextInt(MAX_SMALL); this.collisions += rand.nextInt(MAX_SMALL); } return new PortStatsEntry(this.number, this.rxPackets, this.txPackets, this.rxBytes, this.txBytes, this.rxDropped, this.txDropped, this.rxErrors, this.txErrors, this.rxFrameErr, this.rxOverErr, this.rxCrcErr, this.collisions); } }
|
IPortImpl implements IPort { @Override public PortStatsEntry getStats() { if (isForwarding && isActive) { this.rxPackets += rand.nextInt(MAX_LARGE); this.txPackets += rand.nextInt(MAX_LARGE); this.rxBytes += rand.nextInt(MAX_LARGE); this.txBytes += rand.nextInt(MAX_LARGE); this.rxDropped += rand.nextInt(MAX_SMALL); this.txDropped += rand.nextInt(MAX_SMALL); this.rxErrors += rand.nextInt(MAX_SMALL); this.txErrors += rand.nextInt(MAX_SMALL); this.rxFrameErr += rand.nextInt(MAX_SMALL); this.rxOverErr += rand.nextInt(MAX_SMALL); this.rxCrcErr += rand.nextInt(MAX_SMALL); this.collisions += rand.nextInt(MAX_SMALL); } return new PortStatsEntry(this.number, this.rxPackets, this.txPackets, this.rxBytes, this.txBytes, this.rxDropped, this.txDropped, this.rxErrors, this.txErrors, this.rxFrameErr, this.rxOverErr, this.rxCrcErr, this.collisions); } IPortImpl(ISwitchImpl sw, PortStateType state, int portNumber); }
|
IPortImpl implements IPort { @Override public PortStatsEntry getStats() { if (isForwarding && isActive) { this.rxPackets += rand.nextInt(MAX_LARGE); this.txPackets += rand.nextInt(MAX_LARGE); this.rxBytes += rand.nextInt(MAX_LARGE); this.txBytes += rand.nextInt(MAX_LARGE); this.rxDropped += rand.nextInt(MAX_SMALL); this.txDropped += rand.nextInt(MAX_SMALL); this.rxErrors += rand.nextInt(MAX_SMALL); this.txErrors += rand.nextInt(MAX_SMALL); this.rxFrameErr += rand.nextInt(MAX_SMALL); this.rxOverErr += rand.nextInt(MAX_SMALL); this.rxCrcErr += rand.nextInt(MAX_SMALL); this.collisions += rand.nextInt(MAX_SMALL); } return new PortStatsEntry(this.number, this.rxPackets, this.txPackets, this.rxBytes, this.txBytes, this.rxDropped, this.txDropped, this.rxErrors, this.txErrors, this.rxFrameErr, this.rxOverErr, this.rxCrcErr, this.collisions); } IPortImpl(ISwitchImpl sw, PortStateType state, int portNumber); InfoMessage makePorChangetMessage(); @Override void enable(); @Override void disable(); @Override void block(); @Override void unblock(); void modPort(PortModMessage message); @Override boolean isActive(); @Override boolean isForwarding(); @Override int getNumber(); @Override void setLatency(int latency); @Override int getLatency(); @Override String getPeerSwitch(); @Override void setPeerSwitch(String peerSwitch); @Override void setPeerPortNum(int peerPortNum); @Override int getPeerPortNum(); @Override void setIsl(DatapathId peerSwitch, int peerPortNum); ISwitchImpl getSw(); void setSw(ISwitchImpl sw); @Override boolean isActiveIsl(); @Override PortStatsEntry getStats(); }
|
IPortImpl implements IPort { @Override public PortStatsEntry getStats() { if (isForwarding && isActive) { this.rxPackets += rand.nextInt(MAX_LARGE); this.txPackets += rand.nextInt(MAX_LARGE); this.rxBytes += rand.nextInt(MAX_LARGE); this.txBytes += rand.nextInt(MAX_LARGE); this.rxDropped += rand.nextInt(MAX_SMALL); this.txDropped += rand.nextInt(MAX_SMALL); this.rxErrors += rand.nextInt(MAX_SMALL); this.txErrors += rand.nextInt(MAX_SMALL); this.rxFrameErr += rand.nextInt(MAX_SMALL); this.rxOverErr += rand.nextInt(MAX_SMALL); this.rxCrcErr += rand.nextInt(MAX_SMALL); this.collisions += rand.nextInt(MAX_SMALL); } return new PortStatsEntry(this.number, this.rxPackets, this.txPackets, this.rxBytes, this.txBytes, this.rxDropped, this.txDropped, this.rxErrors, this.txErrors, this.rxFrameErr, this.rxOverErr, this.rxCrcErr, this.collisions); } IPortImpl(ISwitchImpl sw, PortStateType state, int portNumber); InfoMessage makePorChangetMessage(); @Override void enable(); @Override void disable(); @Override void block(); @Override void unblock(); void modPort(PortModMessage message); @Override boolean isActive(); @Override boolean isForwarding(); @Override int getNumber(); @Override void setLatency(int latency); @Override int getLatency(); @Override String getPeerSwitch(); @Override void setPeerSwitch(String peerSwitch); @Override void setPeerPortNum(int peerPortNum); @Override int getPeerPortNum(); @Override void setIsl(DatapathId peerSwitch, int peerPortNum); ISwitchImpl getSw(); void setSw(ISwitchImpl sw); @Override boolean isActiveIsl(); @Override PortStatsEntry getStats(); }
|
@Test public void shouldPrepareFlowUpdateResultWithNeedUpdateFlag() { String flowId = "test_flow_id"; Flow flow = Flow.builder() .flowId(flowId) .srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()) .srcPort(2) .srcVlan(3) .destSwitch(Switch.builder().switchId(new SwitchId(2)).build()) .destPort(4) .destVlan(5) .bandwidth(1000) .allocateProtectedPath(true) .encapsulationType(FlowEncapsulationType.TRANSIT_VLAN) .pathComputationStrategy(PathComputationStrategy.COST) .build(); FlowPatch flowPatch = FlowPatch.builder() .source(PatchEndpoint.builder().switchId(new SwitchId(3)).build()) .build(); UpdateFlowResult result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().portNumber(9).build()).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().vlanId(9).build()).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().innerVlanId(9).build()).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().trackLldpConnectedDevices(true).build()).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().trackArpConnectedDevices(true).build()).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().switchId(new SwitchId(3)).build()).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().portNumber(9).build()).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().vlanId(9).build()).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().innerVlanId(9).build()).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder() .destination(PatchEndpoint.builder().trackLldpConnectedDevices(true).build()) .build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder() .destination(PatchEndpoint.builder().trackArpConnectedDevices(true).build()) .build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().bandwidth(9000L).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().allocateProtectedPath(false).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().diverseFlowId("diverse_flow_id").build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().ignoreBandwidth(true).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().encapsulationType(FlowEncapsulationType.VXLAN).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); flowPatch = FlowPatch.builder().pathComputationStrategy(PathComputationStrategy.LATENCY).build(); result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build(); assertTrue(result.isNeedUpdateFlow()); }
|
@VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDestination(flowPatch, flow); updateRequired |= flowPatch.getBandwidth() != null && flow.getBandwidth() != flowPatch.getBandwidth(); updateRequired |= flowPatch.getAllocateProtectedPath() != null && !flowPatch.getAllocateProtectedPath().equals(flow.isAllocateProtectedPath()); updateRequired |= updateRequiredByDiverseFlowIdField(flowPatch, flow); updateRequired |= flowPatch.getIgnoreBandwidth() != null && flow.isIgnoreBandwidth() != flowPatch.getIgnoreBandwidth(); updateRequired |= flowPatch.getEncapsulationType() != null && !flow.getEncapsulationType().equals(flowPatch.getEncapsulationType()); return UpdateFlowResult.builder() .needUpdateFlow(updateRequired); } FlowOperationsService(RepositoryFactory repositoryFactory, TransactionManager transactionManager); Flow getFlow(String flowId); Set<String> getDiverseFlowsId(String flowId, String groupId); Collection<Flow> getAllFlows(FlowsDumpRequest request); Collection<FlowPath> getFlowPathsForLink(SwitchId srcSwitchId, Integer srcPort,
SwitchId dstSwitchId, Integer dstPort); Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port); Collection<FlowPath> getFlowPathsForSwitch(SwitchId switchId); List<FlowPathDto> getFlowPath(String flowId); Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch); Collection<SwitchConnectedDevice> getFlowConnectedDevice(String flowId); List<FlowRerouteRequest> makeRerouteRequests(
Collection<FlowPath> targetPaths, Set<IslEndpoint> affectedIslEndpoints, String reason); }
|
@Test public void shouldSuccessfulSendDatapoint() { Datapoint datapoint = new Datapoint("metric", timestamp, Collections.emptyMap(), 123); MockedSources sources = new MockedSources(); Testing.withTrackedCluster(clusterParam, (cluster) -> { OpenTsdbTopology topology = new OpenTsdbTopology(makeLaunchEnvironment()); sources.addMockData(OpenTsdbTopology.OTSDB_SPOUT_ID, new Values(null, datapoint)); completeTopologyParam.setMockedSources(sources); StormTopology stormTopology = topology.createTopology(); Map result = Testing.completeTopology(cluster, stormTopology, completeTopologyParam); }); mockServer.verify(REQUEST, VerificationTimes.exactly(1)); }
|
@Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); }
|
OpenTsdbTopology extends AbstractTopology<OpenTsdbTopologyConfig> { @Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); } }
|
OpenTsdbTopology extends AbstractTopology<OpenTsdbTopologyConfig> { @Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); } OpenTsdbTopology(LaunchEnvironment env); }
|
OpenTsdbTopology extends AbstractTopology<OpenTsdbTopologyConfig> { @Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); } OpenTsdbTopology(LaunchEnvironment env); @Override StormTopology createTopology(); static void main(String[] args); }
|
OpenTsdbTopology extends AbstractTopology<OpenTsdbTopologyConfig> { @Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); } OpenTsdbTopology(LaunchEnvironment env); @Override StormTopology createTopology(); static void main(String[] args); }
|
@Test public void shouldSendDatapointRequestsOnlyOnce() throws Exception { Datapoint datapoint = new Datapoint("metric", timestamp, Collections.emptyMap(), 123); MockedSources sources = new MockedSources(); Testing.withTrackedCluster(clusterParam, (cluster) -> { OpenTsdbTopology topology = new OpenTsdbTopology(makeLaunchEnvironment()); sources.addMockData(OpenTsdbTopology.OTSDB_SPOUT_ID, new Values(null, datapoint), new Values(null, datapoint)); completeTopologyParam.setMockedSources(sources); StormTopology stormTopology = topology.createTopology(); Testing.completeTopology(cluster, stormTopology, completeTopologyParam); }); mockServer.verify(REQUEST, VerificationTimes.exactly(1)); }
|
@Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); }
|
OpenTsdbTopology extends AbstractTopology<OpenTsdbTopologyConfig> { @Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); } }
|
OpenTsdbTopology extends AbstractTopology<OpenTsdbTopologyConfig> { @Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); } OpenTsdbTopology(LaunchEnvironment env); }
|
OpenTsdbTopology extends AbstractTopology<OpenTsdbTopologyConfig> { @Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); } OpenTsdbTopology(LaunchEnvironment env); @Override StormTopology createTopology(); static void main(String[] args); }
|
OpenTsdbTopology extends AbstractTopology<OpenTsdbTopologyConfig> { @Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); } OpenTsdbTopology(LaunchEnvironment env); @Override StormTopology createTopology(); static void main(String[] args); }
|
@Test public void shouldSendDatapointRequestsTwice() throws Exception { Datapoint datapoint1 = new Datapoint("metric", timestamp, Collections.emptyMap(), 123); Datapoint datapoint2 = new Datapoint("metric", timestamp, Collections.emptyMap(), 456); MockedSources sources = new MockedSources(); Testing.withTrackedCluster(clusterParam, (cluster) -> { OpenTsdbTopology topology = new OpenTsdbTopology(makeLaunchEnvironment()); sources.addMockData(OpenTsdbTopology.OTSDB_SPOUT_ID, new Values(null, datapoint1), new Values(null, datapoint2)); completeTopologyParam.setMockedSources(sources); StormTopology stormTopology = topology.createTopology(); Testing.completeTopology(cluster, stormTopology, completeTopologyParam); }); mockServer.verify(REQUEST, VerificationTimes.exactly(2)); }
|
@Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); }
|
OpenTsdbTopology extends AbstractTopology<OpenTsdbTopologyConfig> { @Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); } }
|
OpenTsdbTopology extends AbstractTopology<OpenTsdbTopologyConfig> { @Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); } OpenTsdbTopology(LaunchEnvironment env); }
|
OpenTsdbTopology extends AbstractTopology<OpenTsdbTopologyConfig> { @Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); } OpenTsdbTopology(LaunchEnvironment env); @Override StormTopology createTopology(); static void main(String[] args); }
|
OpenTsdbTopology extends AbstractTopology<OpenTsdbTopologyConfig> { @Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(OTSDB_PARSE_BOLT_ID, new DatapointParseBolt(), openTsdbConfig.getDatapointParseBoltExecutors()) .setNumTasks(openTsdbConfig.getDatapointParseBoltWorkers()) .shuffleGrouping(OTSDB_SPOUT_ID); tb.setBolt(OTSDB_FILTER_BOLT_ID, new OpenTSDBFilterBolt(), openTsdbConfig.getFilterBoltExecutors()) .fieldsGrouping(OTSDB_PARSE_BOLT_ID, new Fields("hash")); OpenTsdbClient.Builder tsdbBuilder = OpenTsdbClient .newBuilder(openTsdbConfig.getHosts()) .returnDetails(); if (openTsdbConfig.getClientChunkedRequestsEnabled()) { tsdbBuilder.enableChunkedEncoding(); } OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(tsdbBuilder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER)); openTsdbBolt.withBatchSize(openTsdbConfig.getBatchSize()).withFlushInterval(openTsdbConfig.getFlushInterval()); tb.setBolt(OTSDB_BOLT_ID, openTsdbBolt, openTsdbConfig.getBoltExecutors()) .setNumTasks(openTsdbConfig.getBoltWorkers()) .shuffleGrouping(OTSDB_FILTER_BOLT_ID); return tb.createTopology(); } OpenTsdbTopology(LaunchEnvironment env); @Override StormTopology createTopology(); static void main(String[] args); }
|
@Test public void testCommandBuilder() { List<BaseFlow> response = commandBuilder .buildCommandsToSyncMissingRules(SWITCH_ID_B, Stream.of(1L, 2L, 3L, 4L) .map(effectiveId -> new FlowSegmentCookie(FlowPathDirection.FORWARD, effectiveId)) .map(Cookie::getValue) .collect(Collectors.toList())); assertEquals(4, response.size()); assertTrue(response.get(0) instanceof InstallEgressFlow); assertTrue(response.get(1) instanceof InstallTransitFlow); assertTrue(response.get(2) instanceof InstallOneSwitchFlow); assertTrue(response.get(3) instanceof InstallIngressFlow); }
|
@Override public List<BaseFlow> buildCommandsToSyncMissingRules(SwitchId switchId, List<Long> switchRules) { List<BaseFlow> commands = new ArrayList<>(buildInstallDefaultRuleCommands(switchId, switchRules)); commands.addAll(buildInstallFlowSharedRuleCommands(switchId, switchRules)); flowPathRepository.findBySegmentDestSwitch(switchId) .forEach(flowPath -> { if (switchRules.contains(flowPath.getCookie().getValue())) { PathSegment segment = flowPath.getSegments().stream() .filter(pathSegment -> pathSegment.getDestSwitchId().equals(switchId)) .findAny() .orElseThrow(() -> new IllegalStateException( format("PathSegment not found, path %s, switch %s", flowPath, switchId))); log.info("Rule {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); commands.addAll(buildInstallCommandFromSegment(flowPath, segment)); } }); SwitchProperties switchProperties = getSwitchProperties(switchId); flowPathRepository.findByEndpointSwitch(switchId) .forEach(flowPath -> { if (switchRules.contains(flowPath.getCookie().getValue())) { Flow flow = getFlow(flowPath); if (flowPath.isOneSwitchFlow()) { log.info("One-switch flow {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); commands.add(flowCommandFactory.makeOneSwitchRule(flow, flowPath)); } else if (flowPath.getSrcSwitchId().equals(switchId)) { log.info("Ingress flow {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); if (flowPath.getSegments().isEmpty()) { log.warn("Output port was not found for ingress flow rule"); } else { PathSegment foundIngressSegment = flowPath.getSegments().get(0); EncapsulationResources encapsulationResources = getEncapsulationResources( flowPath, flow); commands.add(flowCommandFactory.buildInstallIngressFlow(flow, flowPath, foundIngressSegment.getSrcPort(), encapsulationResources, foundIngressSegment.isSrcWithMultiTable())); } } } long server42Cookie = flowPath.getCookie().toBuilder() .type(CookieType.SERVER_42_INGRESS) .build() .getValue(); if (switchRules.contains(server42Cookie) && !flowPath.isOneSwitchFlow() && flowPath.getSrcSwitchId().equals(switchId)) { log.info("Ingress server 42 flow {} is to be (re)installed on switch {}", server42Cookie, switchId); if (flowPath.getSegments().isEmpty()) { log.warn("Output port was not found for server 42 ingress flow rule {}", server42Cookie); } else { Flow flow = getFlow(flowPath); PathSegment foundIngressSegment = flowPath.getSegments().get(0); EncapsulationResources encapsulationResources = getEncapsulationResources(flowPath, flow); commands.add(flowCommandFactory.buildInstallServer42IngressFlow( flow, flowPath, foundIngressSegment.getSrcPort(), switchProperties.getServer42Port(), switchProperties.getServer42MacAddress(), encapsulationResources, foundIngressSegment.isSrcWithMultiTable())); } } }); return commands; }
|
CommandBuilderImpl implements CommandBuilder { @Override public List<BaseFlow> buildCommandsToSyncMissingRules(SwitchId switchId, List<Long> switchRules) { List<BaseFlow> commands = new ArrayList<>(buildInstallDefaultRuleCommands(switchId, switchRules)); commands.addAll(buildInstallFlowSharedRuleCommands(switchId, switchRules)); flowPathRepository.findBySegmentDestSwitch(switchId) .forEach(flowPath -> { if (switchRules.contains(flowPath.getCookie().getValue())) { PathSegment segment = flowPath.getSegments().stream() .filter(pathSegment -> pathSegment.getDestSwitchId().equals(switchId)) .findAny() .orElseThrow(() -> new IllegalStateException( format("PathSegment not found, path %s, switch %s", flowPath, switchId))); log.info("Rule {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); commands.addAll(buildInstallCommandFromSegment(flowPath, segment)); } }); SwitchProperties switchProperties = getSwitchProperties(switchId); flowPathRepository.findByEndpointSwitch(switchId) .forEach(flowPath -> { if (switchRules.contains(flowPath.getCookie().getValue())) { Flow flow = getFlow(flowPath); if (flowPath.isOneSwitchFlow()) { log.info("One-switch flow {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); commands.add(flowCommandFactory.makeOneSwitchRule(flow, flowPath)); } else if (flowPath.getSrcSwitchId().equals(switchId)) { log.info("Ingress flow {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); if (flowPath.getSegments().isEmpty()) { log.warn("Output port was not found for ingress flow rule"); } else { PathSegment foundIngressSegment = flowPath.getSegments().get(0); EncapsulationResources encapsulationResources = getEncapsulationResources( flowPath, flow); commands.add(flowCommandFactory.buildInstallIngressFlow(flow, flowPath, foundIngressSegment.getSrcPort(), encapsulationResources, foundIngressSegment.isSrcWithMultiTable())); } } } long server42Cookie = flowPath.getCookie().toBuilder() .type(CookieType.SERVER_42_INGRESS) .build() .getValue(); if (switchRules.contains(server42Cookie) && !flowPath.isOneSwitchFlow() && flowPath.getSrcSwitchId().equals(switchId)) { log.info("Ingress server 42 flow {} is to be (re)installed on switch {}", server42Cookie, switchId); if (flowPath.getSegments().isEmpty()) { log.warn("Output port was not found for server 42 ingress flow rule {}", server42Cookie); } else { Flow flow = getFlow(flowPath); PathSegment foundIngressSegment = flowPath.getSegments().get(0); EncapsulationResources encapsulationResources = getEncapsulationResources(flowPath, flow); commands.add(flowCommandFactory.buildInstallServer42IngressFlow( flow, flowPath, foundIngressSegment.getSrcPort(), switchProperties.getServer42Port(), switchProperties.getServer42MacAddress(), encapsulationResources, foundIngressSegment.isSrcWithMultiTable())); } } }); return commands; } }
|
CommandBuilderImpl implements CommandBuilder { @Override public List<BaseFlow> buildCommandsToSyncMissingRules(SwitchId switchId, List<Long> switchRules) { List<BaseFlow> commands = new ArrayList<>(buildInstallDefaultRuleCommands(switchId, switchRules)); commands.addAll(buildInstallFlowSharedRuleCommands(switchId, switchRules)); flowPathRepository.findBySegmentDestSwitch(switchId) .forEach(flowPath -> { if (switchRules.contains(flowPath.getCookie().getValue())) { PathSegment segment = flowPath.getSegments().stream() .filter(pathSegment -> pathSegment.getDestSwitchId().equals(switchId)) .findAny() .orElseThrow(() -> new IllegalStateException( format("PathSegment not found, path %s, switch %s", flowPath, switchId))); log.info("Rule {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); commands.addAll(buildInstallCommandFromSegment(flowPath, segment)); } }); SwitchProperties switchProperties = getSwitchProperties(switchId); flowPathRepository.findByEndpointSwitch(switchId) .forEach(flowPath -> { if (switchRules.contains(flowPath.getCookie().getValue())) { Flow flow = getFlow(flowPath); if (flowPath.isOneSwitchFlow()) { log.info("One-switch flow {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); commands.add(flowCommandFactory.makeOneSwitchRule(flow, flowPath)); } else if (flowPath.getSrcSwitchId().equals(switchId)) { log.info("Ingress flow {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); if (flowPath.getSegments().isEmpty()) { log.warn("Output port was not found for ingress flow rule"); } else { PathSegment foundIngressSegment = flowPath.getSegments().get(0); EncapsulationResources encapsulationResources = getEncapsulationResources( flowPath, flow); commands.add(flowCommandFactory.buildInstallIngressFlow(flow, flowPath, foundIngressSegment.getSrcPort(), encapsulationResources, foundIngressSegment.isSrcWithMultiTable())); } } } long server42Cookie = flowPath.getCookie().toBuilder() .type(CookieType.SERVER_42_INGRESS) .build() .getValue(); if (switchRules.contains(server42Cookie) && !flowPath.isOneSwitchFlow() && flowPath.getSrcSwitchId().equals(switchId)) { log.info("Ingress server 42 flow {} is to be (re)installed on switch {}", server42Cookie, switchId); if (flowPath.getSegments().isEmpty()) { log.warn("Output port was not found for server 42 ingress flow rule {}", server42Cookie); } else { Flow flow = getFlow(flowPath); PathSegment foundIngressSegment = flowPath.getSegments().get(0); EncapsulationResources encapsulationResources = getEncapsulationResources(flowPath, flow); commands.add(flowCommandFactory.buildInstallServer42IngressFlow( flow, flowPath, foundIngressSegment.getSrcPort(), switchProperties.getServer42Port(), switchProperties.getServer42MacAddress(), encapsulationResources, foundIngressSegment.isSrcWithMultiTable())); } } }); return commands; } CommandBuilderImpl(PersistenceManager persistenceManager, FlowResourcesConfig flowResourcesConfig); }
|
CommandBuilderImpl implements CommandBuilder { @Override public List<BaseFlow> buildCommandsToSyncMissingRules(SwitchId switchId, List<Long> switchRules) { List<BaseFlow> commands = new ArrayList<>(buildInstallDefaultRuleCommands(switchId, switchRules)); commands.addAll(buildInstallFlowSharedRuleCommands(switchId, switchRules)); flowPathRepository.findBySegmentDestSwitch(switchId) .forEach(flowPath -> { if (switchRules.contains(flowPath.getCookie().getValue())) { PathSegment segment = flowPath.getSegments().stream() .filter(pathSegment -> pathSegment.getDestSwitchId().equals(switchId)) .findAny() .orElseThrow(() -> new IllegalStateException( format("PathSegment not found, path %s, switch %s", flowPath, switchId))); log.info("Rule {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); commands.addAll(buildInstallCommandFromSegment(flowPath, segment)); } }); SwitchProperties switchProperties = getSwitchProperties(switchId); flowPathRepository.findByEndpointSwitch(switchId) .forEach(flowPath -> { if (switchRules.contains(flowPath.getCookie().getValue())) { Flow flow = getFlow(flowPath); if (flowPath.isOneSwitchFlow()) { log.info("One-switch flow {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); commands.add(flowCommandFactory.makeOneSwitchRule(flow, flowPath)); } else if (flowPath.getSrcSwitchId().equals(switchId)) { log.info("Ingress flow {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); if (flowPath.getSegments().isEmpty()) { log.warn("Output port was not found for ingress flow rule"); } else { PathSegment foundIngressSegment = flowPath.getSegments().get(0); EncapsulationResources encapsulationResources = getEncapsulationResources( flowPath, flow); commands.add(flowCommandFactory.buildInstallIngressFlow(flow, flowPath, foundIngressSegment.getSrcPort(), encapsulationResources, foundIngressSegment.isSrcWithMultiTable())); } } } long server42Cookie = flowPath.getCookie().toBuilder() .type(CookieType.SERVER_42_INGRESS) .build() .getValue(); if (switchRules.contains(server42Cookie) && !flowPath.isOneSwitchFlow() && flowPath.getSrcSwitchId().equals(switchId)) { log.info("Ingress server 42 flow {} is to be (re)installed on switch {}", server42Cookie, switchId); if (flowPath.getSegments().isEmpty()) { log.warn("Output port was not found for server 42 ingress flow rule {}", server42Cookie); } else { Flow flow = getFlow(flowPath); PathSegment foundIngressSegment = flowPath.getSegments().get(0); EncapsulationResources encapsulationResources = getEncapsulationResources(flowPath, flow); commands.add(flowCommandFactory.buildInstallServer42IngressFlow( flow, flowPath, foundIngressSegment.getSrcPort(), switchProperties.getServer42Port(), switchProperties.getServer42MacAddress(), encapsulationResources, foundIngressSegment.isSrcWithMultiTable())); } } }); return commands; } CommandBuilderImpl(PersistenceManager persistenceManager, FlowResourcesConfig flowResourcesConfig); @Override List<BaseFlow> buildCommandsToSyncMissingRules(SwitchId switchId, List<Long> switchRules); @Override List<RemoveFlow> buildCommandsToRemoveExcessRules(SwitchId switchId,
List<FlowEntry> flows,
List<Long> excessRulesCookies); }
|
CommandBuilderImpl implements CommandBuilder { @Override public List<BaseFlow> buildCommandsToSyncMissingRules(SwitchId switchId, List<Long> switchRules) { List<BaseFlow> commands = new ArrayList<>(buildInstallDefaultRuleCommands(switchId, switchRules)); commands.addAll(buildInstallFlowSharedRuleCommands(switchId, switchRules)); flowPathRepository.findBySegmentDestSwitch(switchId) .forEach(flowPath -> { if (switchRules.contains(flowPath.getCookie().getValue())) { PathSegment segment = flowPath.getSegments().stream() .filter(pathSegment -> pathSegment.getDestSwitchId().equals(switchId)) .findAny() .orElseThrow(() -> new IllegalStateException( format("PathSegment not found, path %s, switch %s", flowPath, switchId))); log.info("Rule {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); commands.addAll(buildInstallCommandFromSegment(flowPath, segment)); } }); SwitchProperties switchProperties = getSwitchProperties(switchId); flowPathRepository.findByEndpointSwitch(switchId) .forEach(flowPath -> { if (switchRules.contains(flowPath.getCookie().getValue())) { Flow flow = getFlow(flowPath); if (flowPath.isOneSwitchFlow()) { log.info("One-switch flow {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); commands.add(flowCommandFactory.makeOneSwitchRule(flow, flowPath)); } else if (flowPath.getSrcSwitchId().equals(switchId)) { log.info("Ingress flow {} is to be (re)installed on switch {}", flowPath.getCookie(), switchId); if (flowPath.getSegments().isEmpty()) { log.warn("Output port was not found for ingress flow rule"); } else { PathSegment foundIngressSegment = flowPath.getSegments().get(0); EncapsulationResources encapsulationResources = getEncapsulationResources( flowPath, flow); commands.add(flowCommandFactory.buildInstallIngressFlow(flow, flowPath, foundIngressSegment.getSrcPort(), encapsulationResources, foundIngressSegment.isSrcWithMultiTable())); } } } long server42Cookie = flowPath.getCookie().toBuilder() .type(CookieType.SERVER_42_INGRESS) .build() .getValue(); if (switchRules.contains(server42Cookie) && !flowPath.isOneSwitchFlow() && flowPath.getSrcSwitchId().equals(switchId)) { log.info("Ingress server 42 flow {} is to be (re)installed on switch {}", server42Cookie, switchId); if (flowPath.getSegments().isEmpty()) { log.warn("Output port was not found for server 42 ingress flow rule {}", server42Cookie); } else { Flow flow = getFlow(flowPath); PathSegment foundIngressSegment = flowPath.getSegments().get(0); EncapsulationResources encapsulationResources = getEncapsulationResources(flowPath, flow); commands.add(flowCommandFactory.buildInstallServer42IngressFlow( flow, flowPath, foundIngressSegment.getSrcPort(), switchProperties.getServer42Port(), switchProperties.getServer42MacAddress(), encapsulationResources, foundIngressSegment.isSrcWithMultiTable())); } } }); return commands; } CommandBuilderImpl(PersistenceManager persistenceManager, FlowResourcesConfig flowResourcesConfig); @Override List<BaseFlow> buildCommandsToSyncMissingRules(SwitchId switchId, List<Long> switchRules); @Override List<RemoveFlow> buildCommandsToRemoveExcessRules(SwitchId switchId,
List<FlowEntry> flows,
List<Long> excessRulesCookies); }
|
@Test public void shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithTransitVlanEncapsulation() { Long cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue(); String inPort = "1"; String inVlan = "10"; String outPort = "2"; FlowEntry flowEntry = buildFlowEntry(cookie, inPort, inVlan, outPort, null, false); RemoveFlow removeFlow = commandBuilder.buildRemoveFlowWithoutMeterFromFlowEntry(SWITCH_ID_A, flowEntry); assertEquals(cookie, removeFlow.getCookie()); DeleteRulesCriteria criteria = removeFlow.getCriteria(); assertEquals(cookie, criteria.getCookie()); assertEquals(Integer.valueOf(inPort), criteria.getInPort()); assertEquals(Integer.valueOf(inVlan), criteria.getEncapsulationId()); assertEquals(Integer.valueOf(outPort), criteria.getOutPort()); }
|
@VisibleForTesting RemoveFlow buildRemoveFlowWithoutMeterFromFlowEntry(SwitchId switchId, FlowEntry entry) { Optional<FlowMatchField> entryMatch = Optional.ofNullable(entry.getMatch()); Optional<FlowInstructions> instructions = Optional.ofNullable(entry.getInstructions()); Optional<FlowApplyActions> applyActions = instructions.map(FlowInstructions::getApplyActions); Integer inPort = entryMatch.map(FlowMatchField::getInPort).map(Integer::valueOf).orElse(null); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; Integer encapsulationId = null; Integer vlan = entryMatch.map(FlowMatchField::getVlanVid).map(Integer::valueOf).orElse(null); if (vlan != null) { encapsulationId = vlan; } else { Integer tunnelId = entryMatch.map(FlowMatchField::getTunnelId).map(Integer::valueOf).orElse(null); if (tunnelId == null) { tunnelId = applyActions.map(FlowApplyActions::getPushVxlan).map(Integer::valueOf).orElse(null); } if (tunnelId != null) { encapsulationId = tunnelId; encapsulationType = FlowEncapsulationType.VXLAN; } } Optional<FlowApplyActions> actions = Optional.ofNullable(entry.getInstructions()) .map(FlowInstructions::getApplyActions); Integer outPort = actions .map(FlowApplyActions::getFlowOutput) .filter(NumberUtils::isNumber) .map(Integer::valueOf) .orElse(null); SwitchId ingressSwitchId = entryMatch.map(FlowMatchField::getEthSrc).map(SwitchId::new).orElse(null); DeleteRulesCriteria criteria = new DeleteRulesCriteria(entry.getCookie(), inPort, encapsulationId, 0, outPort, encapsulationType, ingressSwitchId); return RemoveFlow.builder() .transactionId(transactionIdGenerator.generate()) .flowId("SWMANAGER_BATCH_REMOVE") .cookie(entry.getCookie()) .switchId(switchId) .criteria(criteria) .build(); }
|
CommandBuilderImpl implements CommandBuilder { @VisibleForTesting RemoveFlow buildRemoveFlowWithoutMeterFromFlowEntry(SwitchId switchId, FlowEntry entry) { Optional<FlowMatchField> entryMatch = Optional.ofNullable(entry.getMatch()); Optional<FlowInstructions> instructions = Optional.ofNullable(entry.getInstructions()); Optional<FlowApplyActions> applyActions = instructions.map(FlowInstructions::getApplyActions); Integer inPort = entryMatch.map(FlowMatchField::getInPort).map(Integer::valueOf).orElse(null); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; Integer encapsulationId = null; Integer vlan = entryMatch.map(FlowMatchField::getVlanVid).map(Integer::valueOf).orElse(null); if (vlan != null) { encapsulationId = vlan; } else { Integer tunnelId = entryMatch.map(FlowMatchField::getTunnelId).map(Integer::valueOf).orElse(null); if (tunnelId == null) { tunnelId = applyActions.map(FlowApplyActions::getPushVxlan).map(Integer::valueOf).orElse(null); } if (tunnelId != null) { encapsulationId = tunnelId; encapsulationType = FlowEncapsulationType.VXLAN; } } Optional<FlowApplyActions> actions = Optional.ofNullable(entry.getInstructions()) .map(FlowInstructions::getApplyActions); Integer outPort = actions .map(FlowApplyActions::getFlowOutput) .filter(NumberUtils::isNumber) .map(Integer::valueOf) .orElse(null); SwitchId ingressSwitchId = entryMatch.map(FlowMatchField::getEthSrc).map(SwitchId::new).orElse(null); DeleteRulesCriteria criteria = new DeleteRulesCriteria(entry.getCookie(), inPort, encapsulationId, 0, outPort, encapsulationType, ingressSwitchId); return RemoveFlow.builder() .transactionId(transactionIdGenerator.generate()) .flowId("SWMANAGER_BATCH_REMOVE") .cookie(entry.getCookie()) .switchId(switchId) .criteria(criteria) .build(); } }
|
CommandBuilderImpl implements CommandBuilder { @VisibleForTesting RemoveFlow buildRemoveFlowWithoutMeterFromFlowEntry(SwitchId switchId, FlowEntry entry) { Optional<FlowMatchField> entryMatch = Optional.ofNullable(entry.getMatch()); Optional<FlowInstructions> instructions = Optional.ofNullable(entry.getInstructions()); Optional<FlowApplyActions> applyActions = instructions.map(FlowInstructions::getApplyActions); Integer inPort = entryMatch.map(FlowMatchField::getInPort).map(Integer::valueOf).orElse(null); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; Integer encapsulationId = null; Integer vlan = entryMatch.map(FlowMatchField::getVlanVid).map(Integer::valueOf).orElse(null); if (vlan != null) { encapsulationId = vlan; } else { Integer tunnelId = entryMatch.map(FlowMatchField::getTunnelId).map(Integer::valueOf).orElse(null); if (tunnelId == null) { tunnelId = applyActions.map(FlowApplyActions::getPushVxlan).map(Integer::valueOf).orElse(null); } if (tunnelId != null) { encapsulationId = tunnelId; encapsulationType = FlowEncapsulationType.VXLAN; } } Optional<FlowApplyActions> actions = Optional.ofNullable(entry.getInstructions()) .map(FlowInstructions::getApplyActions); Integer outPort = actions .map(FlowApplyActions::getFlowOutput) .filter(NumberUtils::isNumber) .map(Integer::valueOf) .orElse(null); SwitchId ingressSwitchId = entryMatch.map(FlowMatchField::getEthSrc).map(SwitchId::new).orElse(null); DeleteRulesCriteria criteria = new DeleteRulesCriteria(entry.getCookie(), inPort, encapsulationId, 0, outPort, encapsulationType, ingressSwitchId); return RemoveFlow.builder() .transactionId(transactionIdGenerator.generate()) .flowId("SWMANAGER_BATCH_REMOVE") .cookie(entry.getCookie()) .switchId(switchId) .criteria(criteria) .build(); } CommandBuilderImpl(PersistenceManager persistenceManager, FlowResourcesConfig flowResourcesConfig); }
|
CommandBuilderImpl implements CommandBuilder { @VisibleForTesting RemoveFlow buildRemoveFlowWithoutMeterFromFlowEntry(SwitchId switchId, FlowEntry entry) { Optional<FlowMatchField> entryMatch = Optional.ofNullable(entry.getMatch()); Optional<FlowInstructions> instructions = Optional.ofNullable(entry.getInstructions()); Optional<FlowApplyActions> applyActions = instructions.map(FlowInstructions::getApplyActions); Integer inPort = entryMatch.map(FlowMatchField::getInPort).map(Integer::valueOf).orElse(null); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; Integer encapsulationId = null; Integer vlan = entryMatch.map(FlowMatchField::getVlanVid).map(Integer::valueOf).orElse(null); if (vlan != null) { encapsulationId = vlan; } else { Integer tunnelId = entryMatch.map(FlowMatchField::getTunnelId).map(Integer::valueOf).orElse(null); if (tunnelId == null) { tunnelId = applyActions.map(FlowApplyActions::getPushVxlan).map(Integer::valueOf).orElse(null); } if (tunnelId != null) { encapsulationId = tunnelId; encapsulationType = FlowEncapsulationType.VXLAN; } } Optional<FlowApplyActions> actions = Optional.ofNullable(entry.getInstructions()) .map(FlowInstructions::getApplyActions); Integer outPort = actions .map(FlowApplyActions::getFlowOutput) .filter(NumberUtils::isNumber) .map(Integer::valueOf) .orElse(null); SwitchId ingressSwitchId = entryMatch.map(FlowMatchField::getEthSrc).map(SwitchId::new).orElse(null); DeleteRulesCriteria criteria = new DeleteRulesCriteria(entry.getCookie(), inPort, encapsulationId, 0, outPort, encapsulationType, ingressSwitchId); return RemoveFlow.builder() .transactionId(transactionIdGenerator.generate()) .flowId("SWMANAGER_BATCH_REMOVE") .cookie(entry.getCookie()) .switchId(switchId) .criteria(criteria) .build(); } CommandBuilderImpl(PersistenceManager persistenceManager, FlowResourcesConfig flowResourcesConfig); @Override List<BaseFlow> buildCommandsToSyncMissingRules(SwitchId switchId, List<Long> switchRules); @Override List<RemoveFlow> buildCommandsToRemoveExcessRules(SwitchId switchId,
List<FlowEntry> flows,
List<Long> excessRulesCookies); }
|
CommandBuilderImpl implements CommandBuilder { @VisibleForTesting RemoveFlow buildRemoveFlowWithoutMeterFromFlowEntry(SwitchId switchId, FlowEntry entry) { Optional<FlowMatchField> entryMatch = Optional.ofNullable(entry.getMatch()); Optional<FlowInstructions> instructions = Optional.ofNullable(entry.getInstructions()); Optional<FlowApplyActions> applyActions = instructions.map(FlowInstructions::getApplyActions); Integer inPort = entryMatch.map(FlowMatchField::getInPort).map(Integer::valueOf).orElse(null); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; Integer encapsulationId = null; Integer vlan = entryMatch.map(FlowMatchField::getVlanVid).map(Integer::valueOf).orElse(null); if (vlan != null) { encapsulationId = vlan; } else { Integer tunnelId = entryMatch.map(FlowMatchField::getTunnelId).map(Integer::valueOf).orElse(null); if (tunnelId == null) { tunnelId = applyActions.map(FlowApplyActions::getPushVxlan).map(Integer::valueOf).orElse(null); } if (tunnelId != null) { encapsulationId = tunnelId; encapsulationType = FlowEncapsulationType.VXLAN; } } Optional<FlowApplyActions> actions = Optional.ofNullable(entry.getInstructions()) .map(FlowInstructions::getApplyActions); Integer outPort = actions .map(FlowApplyActions::getFlowOutput) .filter(NumberUtils::isNumber) .map(Integer::valueOf) .orElse(null); SwitchId ingressSwitchId = entryMatch.map(FlowMatchField::getEthSrc).map(SwitchId::new).orElse(null); DeleteRulesCriteria criteria = new DeleteRulesCriteria(entry.getCookie(), inPort, encapsulationId, 0, outPort, encapsulationType, ingressSwitchId); return RemoveFlow.builder() .transactionId(transactionIdGenerator.generate()) .flowId("SWMANAGER_BATCH_REMOVE") .cookie(entry.getCookie()) .switchId(switchId) .criteria(criteria) .build(); } CommandBuilderImpl(PersistenceManager persistenceManager, FlowResourcesConfig flowResourcesConfig); @Override List<BaseFlow> buildCommandsToSyncMissingRules(SwitchId switchId, List<Long> switchRules); @Override List<RemoveFlow> buildCommandsToRemoveExcessRules(SwitchId switchId,
List<FlowEntry> flows,
List<Long> excessRulesCookies); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.