use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 in project netvirt by opendaylight.
the class EvpnUtils method withdrawEvpnRT2Routes.
public void withdrawEvpnRT2Routes(EvpnAugmentation evpnAugmentation, String elanName) {
if (evpnAugmentation == null || evpnAugmentation.getEvpnName() == null) {
LOG.trace("withdrawEvpnRT2Routes, evpnAugmentation is null");
return;
}
String evpnName = evpnAugmentation.getEvpnName();
String rd = vpnManager.getVpnRd(broker, evpnName);
if (rd == null) {
LOG.debug("withdrawEvpnRT2Routes : rd is null for {}", elanName);
return;
}
List<MacEntry> macEntries = elanUtils.getElanMacEntries(elanName);
if (macEntries == null || macEntries.isEmpty()) {
LOG.debug("withdrawEvpnRT2Routes : macEntries is empty for elan {} ", elanName);
return;
}
for (MacEntry macEntry : macEntries) {
if (!isIpv4PrefixAvailable.test(macEntry)) {
LOG.debug("withdrawEvpnRT2Routes macEntry does not have IPv4 prefix {}", macEntry);
continue;
}
String prefix = macEntry.getIpPrefix().getIpv4Address().getValue();
LOG.info("Withdrawing routes with rd {}, prefix {}", rd, prefix);
bgpManager.withdrawPrefix(rd, prefix);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 in project netvirt by opendaylight.
the class SubnetRoutePacketInHandler method onPacketReceived.
@Override
public void onPacketReceived(PacketReceived notification) {
short tableId = notification.getTableId().getValue();
LOG.trace("{} onPacketReceived: Packet punted from table {}", LOGGING_PREFIX, tableId);
byte[] data = notification.getPayload();
if (notification.getMatch() == null || notification.getMatch().getMetadata() == null) {
LOG.error("{} onPacketReceived: Received from table {} where the match or metadata are null", LOGGING_PREFIX, tableId);
return;
}
BigInteger metadata = notification.getMatch().getMetadata().getMetadata();
Ethernet res = new Ethernet();
if (tableId == NwConstants.L3_SUBNET_ROUTE_TABLE) {
LOG.trace("{} onPacketReceived: Some packet received as {}", LOGGING_PREFIX, notification);
try {
res.deserialize(data, 0, data.length * NetUtils.NUM_BITS_IN_A_BYTE);
} catch (PacketException e) {
LOG.error("{} onPacketReceived: Failed to decode Packet ", LOGGING_PREFIX, e);
VpnManagerCounters.subnet_route_packet_failed.inc();
return;
}
try {
Packet pkt = res.getPayload();
if (pkt instanceof IPv4) {
IPv4 ipv4 = (IPv4) pkt;
byte[] srcIp = Ints.toByteArray(ipv4.getSourceAddress());
byte[] dstIp = Ints.toByteArray(ipv4.getDestinationAddress());
String dstIpStr = NWUtil.toStringIpAddress(dstIp);
String srcIpStr = NWUtil.toStringIpAddress(srcIp);
// It is an ARP request on a configured VPN. So we must
// attempt to respond.
long vpnId = MetaDataUtil.getVpnIdFromMetadata(metadata);
LOG.info("{} onPacketReceived: Processing IPv4 Packet received with Source IP {} and Target IP {}" + " and vpnId {}", LOGGING_PREFIX, srcIpStr, dstIpStr, vpnId);
Optional<VpnIds> vpnIdsOptional = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, VpnUtil.getVpnIdToVpnInstanceIdentifier(vpnId));
if (!vpnIdsOptional.isPresent()) {
// Donot trigger subnetroute logic for packets from
// unknown VPNs
VpnManagerCounters.subnet_route_packet_ignored.inc();
LOG.info("{} onPacketReceived: Ignoring IPv4 packet with destination Ip {} and source Ip {}" + " as it came on unknown VPN with ID {}", LOGGING_PREFIX, dstIpStr, srcIpStr, vpnId);
return;
}
String vpnIdVpnInstanceName = vpnIdsOptional.get().getVpnInstanceName();
if (VpnUtil.getNeutronPortFromVpnPortFixedIp(dataBroker, vpnIdVpnInstanceName, dstIpStr) != null) {
VpnManagerCounters.subnet_route_packet_ignored.inc();
LOG.info("{} onPacketReceived: IPv4 Packet received with Target IP {} source IP {} vpnId {} " + "is a valid Neutron port,ignoring subnet route processing", LOGGING_PREFIX, dstIpStr, srcIp, vpnId);
return;
}
if (VpnUtil.getLearntVpnVipToPort(dataBroker, vpnIdVpnInstanceName, dstIpStr) != null) {
VpnManagerCounters.subnet_route_packet_ignored.inc();
LOG.info("{} onPacketReceived: IPv4 Packet received with Target IP {} source Ip {} vpnId {}" + " is an already discovered IPAddress, ignoring subnet route processing", LOGGING_PREFIX, dstIpStr, srcIp, vpnId);
return;
}
long elanTag = MetaDataUtil.getElanTagFromMetadata(metadata);
if (elanTag == 0L) {
VpnManagerCounters.subnet_route_packet_failed.inc();
LOG.error("{} onPacketReceived: elanTag value from metadata found to be 0, for IPv4 " + " Packet received with Target IP {} src Ip {} vpnId {}", LOGGING_PREFIX, dstIpStr, srcIp, vpnId);
return;
}
if (!vpnIdsOptional.get().isExternalVpn()) {
handleInternalVpnSubnetRoutePacket(metadata, dstIp, srcIpStr, dstIpStr, ipv4.getDestinationAddress(), vpnIdVpnInstanceName, elanTag);
return;
}
byte[] srcMac = res.getSourceMACAddress();
handleBgpVpnSubnetRoute(ipv4, srcMac, dstIp, dstIpStr, srcIpStr, elanTag);
}
} catch (UnknownHostException | InterruptedException | ExecutionException ex) {
// Failed to handle packet
VpnManagerCounters.subnet_route_packet_failed.inc();
LOG.error("{} onPacketReceived: Failed to handle subnetroute packet.", LOGGING_PREFIX, ex);
}
return;
}
// All Arp responses learning for invisble IPs is handled by
// ArpNotificationHandler
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 in project netvirt by opendaylight.
the class AclMatchesTest method buildIpv4MatchTest.
@Test
public void buildIpv4MatchTest() {
AceIpv4Builder aceIpv4 = new AceIpv4Builder();
aceIpv4.setDestinationIpv4Network(new Ipv4Prefix(IPV4_DST_STR));
aceIpv4.setSourceIpv4Network(new Ipv4Prefix(IPV4_SRC_STR));
AceIpBuilder aceIpBuilder = new AceIpBuilder();
aceIpBuilder.setAceIpVersion(aceIpv4.build());
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// The layer3 match should be there with src/dst values
Ipv4Match l3 = (Ipv4Match) matchBuilder.getLayer3Match();
assertNotNull(l3);
assertEquals(l3.getIpv4Destination().getValue().toString(), IPV4_DST_STR);
assertEquals(l3.getIpv4Source().getValue().toString(), IPV4_SRC_STR);
// There should be an IPv4 etherType set
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetType().getType().getValue(), Long.valueOf(NwConstants.ETHTYPE_IPV4));
// The rest should be null
assertNull(matchBuilder.getIpMatch());
assertNull(matchBuilder.getLayer4Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 in project netvirt by opendaylight.
the class AclMatchesTest method buildIpv4DscpMatchTest.
@Test
public void buildIpv4DscpMatchTest() {
AceIpBuilder aceIpBuilder = new AceIpBuilder();
aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
aceIpBuilder.setDscp(new Dscp(DSCP_VALUE));
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// There should be an IPv4 etherType set
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetType().getType().getValue(), Long.valueOf(NwConstants.ETHTYPE_IPV4));
// Check the DSCP value
IpMatch ipMatch = matchBuilder.getIpMatch();
assertNotNull(ipMatch);
assertEquals(ipMatch.getIpDscp().getValue(), Short.valueOf(DSCP_VALUE));
// The rest should be null
assertNull(matchBuilder.getLayer3Match());
assertNull(matchBuilder.getLayer4Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 in project netvirt by opendaylight.
the class IngressAclServiceImpl method programIpv4BroadcastRule.
/**
* Programs IPv4 broadcast rules.
*
* @param port the Acl Interface port
* @param addOrRemove whether to delete or add flow
*/
private void programIpv4BroadcastRule(AclInterface port, int addOrRemove) {
BigInteger dpId = port.getDpId();
int lportTag = port.getLPortTag();
MatchInfoBase lportMatchInfo = AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode);
List<IpPrefixOrAddress> cidrs = port.getSubnetIpPrefixes();
if (cidrs != null) {
List<String> broadcastAddresses = AclServiceUtils.getIpBroadcastAddresses(cidrs);
for (String broadcastAddress : broadcastAddresses) {
List<MatchInfoBase> matches = AclServiceUtils.buildBroadcastIpV4Matches(broadcastAddress);
matches.add(lportMatchInfo);
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionGotoTable(getAclConntrackClassifierTable()));
String flowName = "Ingress_v4_Broadcast_" + dpId + "_" + lportTag + "_" + broadcastAddress + "_Permit";
syncFlow(dpId, getAclAntiSpoofingTable(), flowName, AclConstants.PROTO_MATCH_PRIORITY, "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
}
} else {
LOG.warn("IP Broadcast CIDRs are missing for port {}", port.getInterfaceId());
}
}
Aggregations