use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.Flags in project openflowplugin by opendaylight.
the class MultipartReplyMeterConfigDeserializerTest method deserializeDrop.
@Test
public void deserializeDrop() throws Exception {
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
writeCommonAtributes(buffer);
buffer.writeShort(OFPMBTDROP);
buffer.writeShort(SUB_ITEM);
buffer.writeInt(DROP_RATE);
buffer.writeInt(DROP_BURST_SIZE);
buffer.writeZero(PADDING_IN_METER_BAND_DROP_HEADER);
final MultipartReplyMeterConfig reply = (MultipartReplyMeterConfig) deserializeMultipart(buffer);
assertEquals(METER_ID, reply.getMeterConfigStats().get(0).getMeterId().getValue().intValue());
assertEquals(FLAGS, reply.getMeterConfigStats().get(0).getFlags());
final Drop drop = (Drop) reply.getMeterConfigStats().get(0).getMeterBandHeaders().getMeterBandHeader().get(0).getBandType();
assertEquals(DROP_RATE, drop.getDropRate().intValue());
assertEquals(DROP_BURST_SIZE, drop.getDropBurstSize().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.Flags in project netvirt by opendaylight.
the class ConntrackBasedSnatService method addOutboundTblEntry.
protected void addOutboundTblEntry(TypedWriteTransaction<Configuration> confTx, Uint64 dpnId, Uint32 routerId, String externalIp, int elanId, String extGwMacAddress) {
LOG.info("createOutboundTblEntry : dpId {} and routerId {}", dpnId, routerId);
List<MatchInfoBase> matches = new ArrayList<>();
matches.add(MatchEthernetType.IPV4);
matches.add(new NxMatchCtState(TRACKED_NEW_CT_STATE, TRACKED_NEW_CT_MASK));
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId.longValue()), MetaDataUtil.METADATA_MASK_VRFID));
List<ActionInfo> actionsInfos = new ArrayList<>();
actionsInfos.add(new ActionSetFieldEthernetSource(new MacAddress(extGwMacAddress)));
List<NxCtAction> ctActionsListCommit = new ArrayList<>();
int rangePresent = NxActionNatRangePresent.NXNATRANGEIPV4MIN.getIntValue();
int flags = NxActionNatFlags.NXNATFSRC.getIntValue();
NxCtAction nxCtActionCommit = new ActionNxConntrack.NxNat(0, flags, rangePresent, IpPrefixOrAddressBuilder.getDefaultInstance(externalIp).getIpAddress(), null, 0, 0);
ctActionsListCommit.add(nxCtActionCommit);
int ctCommitFlag = 1;
ActionNxConntrack actionNxConntrackSubmit = new ActionNxConntrack(ctCommitFlag, 0, elanId, NwConstants.NAPT_PFIB_TABLE, ctActionsListCommit);
actionsInfos.add(actionNxConntrackSubmit);
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfos));
String flowRef = getFlowRef(dpnId, NwConstants.OUTBOUND_NAPT_TABLE, routerId);
NatUtil.addFlow(confTx, mdsalManager, dpnId, NwConstants.OUTBOUND_NAPT_TABLE, flowRef, NatConstants.SNAT_NEW_FLOW_PRIORITY, flowRef, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.Flags in project netvirt by opendaylight.
the class Ipv6PktHandlerTest method testonPacketReceivedRouterSolicitationWithMultipleSubnets.
@Test
public void testonPacketReceivedRouterSolicitationWithMultipleSubnets() throws Exception {
VirtualPort intf = Mockito.mock(VirtualPort.class);
when(intf.getDpId()).thenReturn(Uint64.valueOf(1));
when(intf.getMacAddress()).thenReturn("50:7B:9D:78:54:F3");
when(intf.getIntfUUID()).thenReturn(Uuid.getDefaultInstance("ddec9dba-d831-4ad7-84b9-00d7f65f052f"));
when(ifMgrInstance.obtainV6Interface(any())).thenReturn(intf);
when(ifMgrInstance.getInterfaceNameFromTag(anyLong())).thenReturn("ddec9dba-d831-4ad7-84b9-00d7f65f052f");
when(ifMgrInstance.getRouterV6InterfaceForNetwork(any())).thenReturn(intf);
List<Action> actions = new ArrayList<>();
actions.add(new ActionNxResubmit(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE).buildAction());
when(ifMgrInstance.getEgressAction(any())).thenReturn(actions);
when(pktProcessService.transmitPacket(any())).thenReturn(Mockito.mock(ListenableFuture.class));
IpAddress gwIpAddress = Mockito.mock(IpAddress.class);
when(gwIpAddress.getIpv4Address()).thenReturn(null);
when(gwIpAddress.getIpv6Address()).thenReturn(new Ipv6Address("2001:db8:1111::1"));
VirtualSubnet v6Subnet1 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix(new Ipv6Prefix("2001:db8:1111::/64"))).ipv6AddressMode(Ipv6ServiceConstants.IPV6_SLAAC).ipv6RAMode(Ipv6ServiceConstants.IPV6_SLAAC).build();
VirtualRouter virtualRouter = VirtualRouter.builder().build();
v6Subnet1.setRouter(virtualRouter);
VirtualSubnet v6Subnet2 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix(new Ipv6Prefix("2001:db8:2222::/64"))).ipv6AddressMode(Ipv6ServiceConstants.IPV6_DHCPV6_STATELESS).ipv6RAMode(Ipv6ServiceConstants.IPV6_DHCPV6_STATELESS).build();
v6Subnet2.setRouter(virtualRouter);
VirtualSubnet v6Subnet3 = VirtualSubnet.builder().gatewayIp(gwIpAddress).subnetCidr(new IpPrefix(new Ipv6Prefix("2001:db8:3333::/64"))).ipv6AddressMode(Ipv6ServiceConstants.IPV6_DHCPV6_STATEFUL).ipv6RAMode(Ipv6ServiceConstants.IPV6_DHCPV6_STATEFUL).build();
v6Subnet3.setRouter(virtualRouter);
List<VirtualSubnet> subnetList = new ArrayList<>();
subnetList.add(v6Subnet1);
subnetList.add(v6Subnet2);
subnetList.add(v6Subnet3);
when(intf.getSubnets()).thenReturn(subnetList);
Uint64 dpnId = Uint64.valueOf("1");
NodeConnectorRef ncRef = MDSALUtil.getDefaultNodeConnRef(dpnId);
Uint64 mdata = Uint64.valueOf(0x1000000);
Metadata metadata = new MetadataBuilder().setMetadata(mdata).build();
MatchBuilder matchbuilder = new MatchBuilder().setMetadata(metadata);
pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
"33 33 00 00 00 02", // Source MAC
"FA 16 3E 69 2C F3", // IPv6
"86 DD", // Version 6, traffic class E0, no flowlabel
"60 00 00 00", // Payload length
"00 10", // Next header is ICMPv6
"3A", // Hop limit
"FF", // Source IP
"FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // Destination IP
"FF 02 00 00 00 00 00 00 00 00 00 00 00 00 00 02", // ICMPv6 router solicitation
"85", // Code
"00", // Checksum (valid)
"B4 47", // ICMPv6 message body
"00 00 00 00", // ICMPv6 Option: Source Link Layer Address
"01", // Length
"01", // Link Layer Address
"FA 16 3E 69 2C F3")).setIngress(ncRef).setMatch(matchbuilder.build()).build());
// wait on this thread until the async job is completed in the packet handler.
waitForPacketProcessing();
verify(pktProcessService, times(1)).transmitPacket(any(TransmitPacketInput.class));
byte[] expectedPayload = ipv6TestUtils.buildPacket(// Destination MAC
"FA 16 3E 69 2C F3", // Source MAC
"50 7B 9D 78 54 F3", // IPv6
"86 DD", // Version 6, traffic class E0, no flowlabel
"60 00 00 00", // Payload length
"00 78", // Next header is ICMPv6
"3A", // Hop limit
"FF", // Source IP
"FE 80 00 00 00 00 00 00 52 7B 9D FF FE 78 54 F3", // Destination IP
"FE 80 00 00 00 00 00 00 F8 16 3E FF FE 69 2C F3", // ICMPv6 router advertisement.
"86", // Code
"00", // Checksum (valid)
"59 41", // Current Hop Limit
"40", // ICMPv6 RA Flags
"C0", // Router Lifetime
"11 94", // Reachable time
"00 01 D4 C0", // Retransmission time.
"00 00 00 00", // Type: Source Link-Layer Option
"01", // Option length
"01", // Source Link layer address
"50 7B 9D 78 54 F3", // Type: Prefix Information
"03", // Option length
"04", // Prefix length
"40", // Prefix flags
"C0", // Valid lifetime
"00 27 8D 00", // Preferred lifetime
"00 09 3A 80", // Reserved
"00 00 00 00", // Prefix
"20 01 0D B8 11 11 00 00 00 00 00 00 00 00 00 00", // Type: Prefix Information
"03", // Option length
"04", // Prefix length
"40", // Prefix flags
"C0", // Valid lifetime
"00 27 8D 00", // Preferred lifetime
"00 09 3A 80", // Reserved
"00 00 00 00", // Prefix
"20 01 0D B8 22 22 00 00 00 00 00 00 00 00 00 00", // Type: Prefix Information
"03", // Option length
"04", // Prefix length
"40", // Prefix flags
"80", // Valid lifetime
"00 27 8D 00", // Preferred lifetime
"00 09 3A 80", // Reserved
"00 00 00 00", // Prefix
"20 01 0D B8 33 33 00 00 00 00 00 00 00 00 00 00");
TransmitPacketInput transmitPacketInput = MDSALUtil.getPacketOut(actions, expectedPayload, dpnId);
verify(pktProcessService).transmitPacket(transmitPacketInput);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.Flags in project netvirt by opendaylight.
the class InterVpnLinkListener method add.
@Override
public void add(InstanceIdentifier<InterVpnLink> identifier, InterVpnLink add) {
String ivpnLinkName = add.getName();
LOG.debug("Reacting to IVpnLink {} creation. Vpn1=[name={} EndpointIp={}] Vpn2=[name={} endpointIP={}]", ivpnLinkName, add.getFirstEndpoint().getVpnUuid(), add.getFirstEndpoint().getIpAddress(), add.getSecondEndpoint().getVpnUuid(), add.getSecondEndpoint().getIpAddress());
// Create VpnLink state
InstanceIdentifier<InterVpnLinkState> vpnLinkStateIid = InterVpnLinkUtil.getInterVpnLinkStateIid(ivpnLinkName);
InterVpnLinkState vpnLinkState = new InterVpnLinkStateBuilder().setInterVpnLinkName(ivpnLinkName).build();
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnLinkStateIid, vpnLinkState);
InterVpnLinkKey key = add.key();
Uuid vpn1Uuid = add.getFirstEndpoint().getVpnUuid();
String vpn1Name = vpn1Uuid.getValue();
Uuid vpn2Uuid = add.getSecondEndpoint().getVpnUuid();
String vpn2Name = vpn2Uuid.getValue();
String vpn1PrimaryRd = vpnUtil.getPrimaryRd(vpn1Name);
String vpn2PrimaryRd = vpnUtil.getPrimaryRd(vpn1Name);
if (!vpnUtil.isVpnPendingDelete(vpn1PrimaryRd) && !vpnUtil.isVpnPendingDelete(vpn2PrimaryRd)) {
if (vpnUtil.getVpnInstance(vpn1Name) == null) {
String errMsg = "InterVpnLink " + ivpnLinkName + " creation error: could not find 1st endpoint Vpn " + vpn1Name;
setInError(vpnLinkStateIid, vpnLinkState, errMsg);
return;
}
if (!checkVpnAvailability(key, vpn1Name)) {
String errMsg = "InterVpnLink " + ivpnLinkName + " creation error: Vpn " + vpn1Name + " is already associated to an inter-vpn-link ";
setInError(vpnLinkStateIid, vpnLinkState, errMsg);
return;
}
// Second VPN
if (vpnUtil.getVpnInstance(vpn2Name) == null) {
String errMsg = "InterVpnLink " + ivpnLinkName + " creation error: could not find 2nd endpoint Vpn " + vpn2Name;
setInError(vpnLinkStateIid, vpnLinkState, errMsg);
return;
}
if (!checkVpnAvailability(key, vpn2Name)) {
String errMsg = "InterVpnLink " + ivpnLinkName + " creation error: Vpn " + vpn2Name + " is already associated with an inter-vpn-link";
setInError(vpnLinkStateIid, vpnLinkState, errMsg);
return;
}
interVpnLinkCache.addInterVpnLinkToCaches(add);
// Wait for VPN Operational data ready
Uint32 vpn1Id = vpnUtil.getVpnId(vpn1Name);
if (VpnConstants.INVALID_ID.equals(vpn1Id)) {
boolean vpn1Ready = vpnOpDataSyncer.waitForVpnDataReady(VpnOpDataSyncer.VpnOpDataType.vpnInstanceToId, vpn1Name, VpnConstants.PER_VPN_INSTANCE_MAX_WAIT_TIME_IN_MILLISECONDS);
if (!vpn1Ready) {
String errMsg = "InterVpnLink " + ivpnLinkName + " creation error: Operational Data for VPN " + vpn1Name + " not ready after " + VpnConstants.PER_INTERFACE_MAX_WAIT_TIME_IN_MILLISECONDS + " milliseconds";
setInError(vpnLinkStateIid, vpnLinkState, errMsg);
return;
}
}
Uint32 vpn2Id = vpnUtil.getVpnId(vpn2Name);
if (VpnConstants.INVALID_ID.equals(vpn2Id)) {
boolean vpn1Ready = vpnOpDataSyncer.waitForVpnDataReady(VpnOpDataSyncer.VpnOpDataType.vpnInstanceToId, vpn2Name, VpnConstants.PER_VPN_INSTANCE_MAX_WAIT_TIME_IN_MILLISECONDS);
if (!vpn1Ready) {
String errMsg = "InterVpnLink " + ivpnLinkName + " creation error: Operational Data for VPN " + vpn2Name + " not ready after " + VpnConstants.PER_INTERFACE_MAX_WAIT_TIME_IN_MILLISECONDS + " milliseconds";
setInError(vpnLinkStateIid, vpnLinkState, errMsg);
return;
}
}
List<Uint64> firstDpnList = ivpnLinkLocator.selectSuitableDpns(add);
if (firstDpnList != null && !firstDpnList.isEmpty()) {
List<Uint64> secondDpnList = firstDpnList;
Long firstVpnLportTag = allocateVpnLinkLportTag(key.getName() + vpn1Name);
Long secondVpnLportTag = allocateVpnLinkLportTag(key.getName() + vpn2Name);
FirstEndpointState firstEndPointState = new FirstEndpointStateBuilder().setVpnUuid(vpn1Uuid).setDpId(firstDpnList).setLportTag(firstVpnLportTag).build();
SecondEndpointState secondEndPointState = new SecondEndpointStateBuilder().setVpnUuid(vpn2Uuid).setDpId(secondDpnList).setLportTag(secondVpnLportTag).build();
interVpnLinkUtil.updateInterVpnLinkState(ivpnLinkName, InterVpnLinkState.State.Active, firstEndPointState, secondEndPointState, interVpnLinkCache);
// Note that in the DPN of the firstEndpoint we install the lportTag of the secondEndpoint and viceversa
interVpnLinkUtil.installLPortDispatcherTableFlow(ivpnLinkName, firstDpnList, vpn2Name, secondVpnLportTag);
interVpnLinkUtil.installLPortDispatcherTableFlow(ivpnLinkName, secondDpnList, vpn1Name, firstVpnLportTag);
// Update the VPN -> DPNs Map.
// Note: when a set of DPNs is calculated for Vpn1, these DPNs are added to the VpnToDpn map of Vpn2.
// Why? because we do the handover from Vpn1 to Vpn2 in those DPNs, so in those DPNs we must know how
// to reach to Vpn2 targets. If new Vpn2 targets are added later, the Fib will be maintained in these
// DPNs even if Vpn2 is not physically present there.
interVpnLinkUtil.updateVpnFootprint(vpn2Name, vpn2PrimaryRd, firstDpnList);
interVpnLinkUtil.updateVpnFootprint(vpn1Name, vpn1PrimaryRd, secondDpnList);
// Program static routes if needed
Optional<InterVpnLinkDataComposite> interVpnLink = interVpnLinkCache.getInterVpnLinkByName(ivpnLinkName);
ivpnLinkService.handleStaticRoutes(interVpnLink.get());
// Now, if the corresponding flags are activated, there will be some routes exchange
ivpnLinkService.exchangeRoutes(interVpnLink.get());
} else {
// If there is no connection to DPNs, the InterVpnLink is created and the InterVpnLinkState is also
// created with the corresponding LPortTags but no DPN is assigned since there is no DPN operative.
Long firstVpnLportTag = allocateVpnLinkLportTag(key.getName() + vpn1Name);
Long secondVpnLportTag = allocateVpnLinkLportTag(key.getName() + vpn2Name);
FirstEndpointState firstEndPointState = new FirstEndpointStateBuilder().setVpnUuid(vpn1Uuid).setLportTag(firstVpnLportTag).setDpId(Collections.emptyList()).build();
SecondEndpointState secondEndPointState = new SecondEndpointStateBuilder().setVpnUuid(vpn2Uuid).setLportTag(secondVpnLportTag).setDpId(Collections.emptyList()).build();
interVpnLinkUtil.updateInterVpnLinkState(ivpnLinkName, InterVpnLinkState.State.Error, firstEndPointState, secondEndPointState, interVpnLinkCache);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.Flags in project bgpcep by opendaylight.
the class CInitiated00StatefulCapabilityTlvParser method parseFlags.
@Override
protected void parseFlags(final StatefulBuilder sb, final ByteBuf buffer) {
final BitArray flags = BitArray.valueOf(buffer, FLAGS_F_LENGTH);
sb.setLspUpdateCapability(flags.get(U_FLAG_OFFSET));
if (flags.get(I_FLAG_OFFSET)) {
sb.addAugmentation(Stateful1.class, new Stateful1Builder().setInitiation(Boolean.TRUE).build());
}
}
Aggregations