use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class AsPathPrepend method applyExportAction.
@Override
public Attributes applyExportAction(final RouteEntryBaseAttributes routeEntryInfo, final BGPRouteEntryExportParameters exportParameters, final Attributes attributes, final SetAsPathPrepend actions) {
final List<Segments> oldSegments = attributes.getAsPath().getSegments();
/*
* We need to check the first segment.
* If it has as-set then new as-sequence with local AS is prepended.
* If it has as-sequence, we may add local AS when it has less than 255 elements.
* Otherwise we need to create new as-sequence for local AS.
*/
final ArrayList<AsNumber> newAsSequence = new ArrayList<>();
newAsSequence.add(new AsNumber(routeEntryInfo.getLocalAs()));
List<Segments> newSegments = new ArrayList<>();
if (oldSegments == null || oldSegments.isEmpty()) {
newSegments = Collections.singletonList(new SegmentsBuilder().setAsSequence(newAsSequence).build());
} else {
final Segments firstSegment = oldSegments.remove(0);
final List<AsNumber> firstAsSequence = firstSegment.getAsSequence();
if (firstAsSequence != null && firstAsSequence.size() < Values.UNSIGNED_BYTE_MAX_VALUE) {
newAsSequence.addAll(firstAsSequence);
newSegments.add(new SegmentsBuilder().setAsSequence(newAsSequence).build());
} else {
newSegments.add(new SegmentsBuilder().setAsSequence(newAsSequence).build());
newSegments.add(firstSegment);
}
newSegments.addAll(oldSegments);
}
return new AttributesBuilder(attributes).setAsPath(new AsPathBuilder().setSegments(newSegments).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class BgpConditionsRegistry method matchExportCondition.
@SuppressWarnings("unchecked")
private boolean matchExportCondition(final RouteEntryBaseAttributes routeEntryInfo, final BGPRouteEntryExportParameters routeEntryExportParameters, final Attributes attributes, final BgpConditions conditions) {
if (!matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())) {
return false;
}
if (!matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())) {
return false;
}
if (!matchOrigin(attributes.getOrigin(), conditions.getOriginEq())) {
return false;
}
if (!matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())) {
return false;
}
if (!matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq())) {
return false;
}
final MatchCommunitySet matchCond = conditions.getMatchCommunitySet();
if (matchCond != null) {
final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchCommunitySet.class);
if (!handler.matchExportCondition(routeEntryInfo, routeEntryExportParameters, handler.getConditionParameter(attributes), matchCond)) {
return false;
}
}
final MatchAsPathSet matchAsPathSet = conditions.getMatchAsPathSet();
if (matchAsPathSet != null) {
final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchAsPathSet.class);
if (!handler.matchExportCondition(routeEntryInfo, routeEntryExportParameters, handler.getConditionParameter(attributes), matchAsPathSet)) {
return false;
}
}
final MatchExtCommunitySet matchExtCommSet = conditions.getMatchExtCommunitySet();
if (matchExtCommSet != null) {
final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchExtCommunitySet.class);
if (!handler.matchExportCondition(routeEntryInfo, routeEntryExportParameters, handler.getConditionParameter(attributes), matchExtCommSet)) {
return false;
}
}
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class BgpConditionsRegistry method matchImportCondition.
@SuppressWarnings("unchecked")
private boolean matchImportCondition(final RouteEntryBaseAttributes routeEntryInfo, final BGPRouteEntryImportParameters routeEntryImportParameters, final Attributes attributes, final BgpConditions conditions) {
if (!matchAsPathLength(attributes.getAsPath(), conditions.getAsPathLength())) {
return false;
}
if (!matchMED(attributes.getMultiExitDisc(), conditions.getMedEq())) {
return false;
}
if (!matchOrigin(attributes.getOrigin(), conditions.getOriginEq())) {
return false;
}
if (!matchNextHopIn(attributes.getCNextHop(), conditions.getNextHopIn())) {
return false;
}
if (!matchLocalPref(attributes.getLocalPref(), conditions.getLocalPrefEq())) {
return false;
}
final MatchCommunitySet matchCond = conditions.getMatchCommunitySet();
if (matchCond != null) {
final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchCommunitySet.class);
if (!handler.matchImportCondition(routeEntryInfo, routeEntryImportParameters, handler.getConditionParameter(attributes), matchCond)) {
return false;
}
}
final MatchAsPathSet matchAsPathSet = conditions.getMatchAsPathSet();
if (matchCond != null) {
final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchAsPathSet.class);
if (!handler.matchImportCondition(routeEntryInfo, routeEntryImportParameters, handler.getConditionParameter(attributes), matchAsPathSet)) {
return false;
}
}
final MatchExtCommunitySet matchExtCommSet = conditions.getMatchExtCommunitySet();
if (matchExtCommSet != null) {
final BgpConditionsPolicy handler = this.bgpConditionsRegistry.get(MatchAsPathSet.class);
if (!handler.matchImportCondition(routeEntryInfo, routeEntryImportParameters, handler.getConditionParameter(attributes), matchExtCommSet)) {
return false;
}
}
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project bgpcep by opendaylight.
the class PrefixesBuilder method createAttributes.
private static Attributes createAttributes(final List<String> extCom, final boolean multiPathSupport, final Ipv4Prefix addressPrefix) {
final AttributesBuilder attBuilder = new AttributesBuilder();
attBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Egp).build());
attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed((long) 0).build());
attBuilder.setLocalPref(new LocalPrefBuilder().setPref(100L).build());
attBuilder.setExtendedCommunities(createExtComm(extCom));
attBuilder.setUnrecognizedAttributes(Collections.emptyList());
final Ipv4PrefixesBuilder prefixes = new Ipv4PrefixesBuilder().setPrefix(addressPrefix);
if (multiPathSupport) {
prefixes.setPathId(new PathId(5L));
}
attBuilder.addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(new MpReachNlriBuilder().setCNextHop(NEXT_HOP).setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(Collections.singletonList(prefixes.build())).build()).build()).build()).build()).build());
return attBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes in project genius by opendaylight.
the class OvsInterfaceStateUpdateHelper method updateState.
public List<ListenableFuture<Void>> updateState(String interfaceName, FlowCapableNodeConnector flowCapableNodeConnectorNew, FlowCapableNodeConnector flowCapableNodeConnectorOld) {
LOG.debug("Updating interface state information for interface: {}", interfaceName);
Interface.OperStatus operStatusNew = InterfaceManagerCommonUtils.getOpState(flowCapableNodeConnectorNew);
MacAddress macAddressNew = flowCapableNodeConnectorNew.getHardwareAddress();
Interface.OperStatus operStatusOld = InterfaceManagerCommonUtils.getOpState(flowCapableNodeConnectorOld);
MacAddress macAddressOld = flowCapableNodeConnectorOld.getHardwareAddress();
boolean opstateModified = !operStatusNew.equals(operStatusOld);
boolean hardwareAddressModified = !macAddressNew.equals(macAddressOld);
if (!opstateModified && !hardwareAddressModified) {
LOG.debug("If State entry for port: {} Not Modified.", interfaceName);
return Collections.emptyList();
}
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceName);
// For monitoring enabled tunnels, skip opstate update
if (isTunnelInterface(iface) && !modifyTunnelOpState(iface, opstateModified)) {
LOG.debug("skip interface-state updation for monitoring enabled tunnel interface {}", interfaceName);
opstateModified = false;
}
if (!opstateModified && !hardwareAddressModified) {
LOG.debug("If State entry for port: {} Not Modified.", interfaceName);
return Collections.emptyList();
}
InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
if (hardwareAddressModified) {
LOG.debug("Hw-Address Modified for Port: {}", interfaceName);
PhysAddress physAddress = new PhysAddress(macAddressNew.getValue());
ifaceBuilder.setPhysAddress(physAddress);
}
if (opstateModified) {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
// modify the attributes in interface operational DS
handleInterfaceStateUpdates(iface, tx, ifaceBuilder, true, interfaceName, flowCapableNodeConnectorNew.getName(), operStatusNew);
// start/stop monitoring based on opState
if (isTunnelInterface(iface)) {
handleTunnelMonitoringUpdates(iface.getAugmentation(IfTunnel.class), iface.getName(), operStatusNew);
}
}));
} else {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
// modify the attributes in interface operational DS
handleInterfaceStateUpdates(iface, tx, ifaceBuilder, false, interfaceName, flowCapableNodeConnectorNew.getName(), operStatusNew);
}));
}
}
Aggregations