use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project openflowplugin by opendaylight.
the class MatchV10Convertor method convertL3Ipv4SrcMatch.
/**
* Method splits the IP address and its mask and set their respective values in MatchV10Builder instance.
* Wildcard value of the IP mask will be determined by Openflow java encoding library.
*
* @param matchBuilder match builder
* @param ipv4 ip v4 match
*/
private static void convertL3Ipv4SrcMatch(final MatchV10Builder matchBuilder, final Ipv4Match ipv4) {
if (ipv4.getIpv4Source() != null) {
Iterator<String> addressParts = IpConversionUtil.PREFIX_SPLITTER.split(ipv4.getIpv4Source().getValue()).iterator();
Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
int prefix = buildPrefix(addressParts);
matchBuilder.setNwSrc(ipv4Address);
matchBuilder.setNwSrcMask((short) prefix);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project openflowplugin by opendaylight.
the class OFPluginFlowTest method createMatch1.
private static MatchBuilder createMatch1() {
MatchBuilder match = new MatchBuilder();
Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
ipv4Match.setIpv4Destination(prefix);
Ipv4Match i4m = ipv4Match.build();
match.setLayer3Match(i4m);
EthernetMatchBuilder eth = new EthernetMatchBuilder();
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
return match;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project netvirt by opendaylight.
the class AclServiceUtils method buildArpIpMatches.
/**
* Builds the arp ip matches.
* @param ipPrefixOrAddress the ip prefix or address
* @return the MatchInfoBase list
*/
public static List<MatchInfoBase> buildArpIpMatches(IpPrefixOrAddress ipPrefixOrAddress) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix();
if (ipPrefix != null) {
Ipv4Prefix ipv4Prefix = ipPrefix.getIpv4Prefix();
if (ipv4Prefix != null && !ipv4Prefix.getValue().equals(AclConstants.IPV4_ALL_NETWORK)) {
flowMatches.add(new MatchArpSpa(ipv4Prefix));
}
} else {
IpAddress ipAddress = ipPrefixOrAddress.getIpAddress();
if (ipAddress != null && ipAddress.getIpv4Address() != null) {
flowMatches.add(new MatchArpSpa(ipAddress.getIpv4Address().getValue(), "32"));
}
}
return flowMatches;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project netvirt by opendaylight.
the class BaseVrfEntryHandler method makeConnectedRoute.
// Allow deprecated TransactionRunner calls for now
@SuppressWarnings("ForbidCertainMethod")
protected void makeConnectedRoute(Uint64 dpId, Uint32 vpnId, VrfEntry vrfEntry, String rd, @Nullable List<InstructionInfo> instructions, int addOrRemove, WriteTransaction tx, @Nullable List<SubTransaction> subTxns) {
if (tx == null) {
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, newTx -> makeConnectedRoute(dpId, vpnId, vrfEntry, rd, instructions, addOrRemove, TransactionAdapter.toWriteTransaction(newTx), subTxns)), LOG, "Error making connected route");
return;
}
LOG.trace("makeConnectedRoute: vrfEntry {}", vrfEntry);
String[] values = vrfEntry.getDestPrefix().split("/");
String ipAddress = values[0];
int prefixLength = values.length == 1 ? 0 : Integer.parseInt(values[1]);
if (addOrRemove == NwConstants.ADD_FLOW) {
LOG.debug("Adding route to DPN {} for rd {} prefix {} ", dpId, rd, vrfEntry.getDestPrefix());
} else {
LOG.debug("Removing route from DPN {} for rd {} prefix {}", dpId, rd, vrfEntry.getDestPrefix());
}
InetAddress destPrefix;
try {
destPrefix = InetAddress.getByName(ipAddress);
} catch (UnknownHostException e) {
LOG.error("Failed to get destPrefix for prefix {} rd {} VpnId {} DPN {}", vrfEntry.getDestPrefix(), rd, vpnId, dpId, e);
return;
}
List<MatchInfo> matches = new ArrayList<>();
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId.longValue()), MetaDataUtil.METADATA_MASK_VRFID));
if (destPrefix instanceof Inet4Address) {
matches.add(MatchEthernetType.IPV4);
if (prefixLength != 0) {
matches.add(new MatchIpv4Destination(destPrefix.getHostAddress(), Integer.toString(prefixLength)));
}
} else {
matches.add(MatchEthernetType.IPV6);
if (prefixLength != 0) {
matches.add(new MatchIpv6Destination(destPrefix.getHostAddress() + "/" + prefixLength));
}
}
int priority = DEFAULT_FIB_FLOW_PRIORITY + prefixLength;
String flowRef = FibUtil.getFlowRef(dpId, NwConstants.L3_FIB_TABLE, rd, priority, destPrefix);
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef, 0, 0, COOKIE_VM_FIB_TABLE, matches, instructions);
Flow flow = flowEntity.getFlowBuilder().build();
String flowId = flowEntity.getFlowId();
FlowKey flowKey = new FlowKey(new FlowId(flowId));
Node nodeDpn = FibUtil.buildDpnNode(dpId);
InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.key()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.BGP) {
SubTransaction subTransaction = new SubTransactionImpl();
if (addOrRemove == NwConstants.ADD_FLOW) {
subTransaction.setInstanceIdentifier(flowInstanceId);
subTransaction.setInstance(flow);
subTransaction.setAction(SubTransaction.CREATE);
} else {
subTransaction.setInstanceIdentifier(flowInstanceId);
subTransaction.setAction(SubTransaction.DELETE);
}
subTxns.add(subTransaction);
}
if (addOrRemove == NwConstants.ADD_FLOW) {
tx.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow);
} else {
tx.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project netvirt by opendaylight.
the class BaseVrfEntryHandler method deleteRemoteRoute.
// Allow deprecated TransactionRunner calls for now
@SuppressWarnings("ForbidCertainMethod")
public void deleteRemoteRoute(@Nullable final Uint64 localDpnId, final Uint64 remoteDpnId, final Uint32 vpnId, final VrfTablesKey vrfTableKey, final VrfEntry vrfEntry, Optional<Routes> extraRouteOptional, @Nullable WriteTransaction tx) {
if (tx == null) {
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, newTx -> deleteRemoteRoute(localDpnId, remoteDpnId, vpnId, vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(newTx))), LOG, "Error deleting remote route");
return;
}
LOG.debug("deleting remote route: prefix={}, vpnId={} localDpnId {} remoteDpnId {}", vrfEntry.getDestPrefix(), vpnId, localDpnId, remoteDpnId);
String rd = vrfTableKey.getRouteDistinguisher();
if (localDpnId != null && !Uint64.ZERO.equals(localDpnId)) {
// localDpnId is not known when clean up happens for last vm for a vpn on a dpn
if (extraRouteOptional.isPresent()) {
nextHopManager.deleteLoadBalancingNextHop(vpnId, remoteDpnId, vrfEntry.getDestPrefix());
}
makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, null, NwConstants.DEL_FLOW, tx, null);
LOG.debug("Successfully delete FIB entry: vrfEntry={}, vpnId={}", vrfEntry.getDestPrefix(), vpnId);
return;
}
// below two reads are kept as is, until best way is found to identify dpnID
VpnNexthop localNextHopInfo = nextHopManager.getVpnNexthop(vpnId, vrfEntry.getDestPrefix());
if (extraRouteOptional.isPresent()) {
nextHopManager.deleteLoadBalancingNextHop(vpnId, remoteDpnId, vrfEntry.getDestPrefix());
} else {
checkDpnDeleteFibEntry(localNextHopInfo, remoteDpnId, vpnId, vrfEntry, rd, tx, null);
}
}
Aggregations