@Override protected String getPhysValue(final PhysAddress physAddress) { return physAddress.getValue(); } }
public void deleteMacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, MacEntry macEntry, WriteTransaction deleteFlowGroupTx) { if (elanInfo == null || interfaceInfo == null) { return; } String macAddress = macEntry.getMacAddress().getValue(); synchronized (macAddress) { LOG.debug("Acquired lock for mac : " + macAddress + ". Proceeding with remove operation."); deleteMacFlows(elanInfo, interfaceInfo, macAddress, /* alsoDeleteSMAC */ true, deleteFlowGroupTx); } }
private TapConnect getTapConnectRequest(final String tapName, final PhysAddress mac, final Long deviceInstance) { final TapConnect tapConnect = new TapConnect(); tapConnect.tapName = tapName.getBytes(); if(mac == null) { tapConnect.useRandomMac = 1; tapConnect.macAddress = new byte[6]; } else { tapConnect.useRandomMac = 0; tapConnect.macAddress = TranslateUtils.parseMac(mac.getValue()); } if(deviceInstance == null) { tapConnect.renumber = 0; } else { tapConnect.renumber = 1; tapConnect.customDevInstance = Math.toIntExact(deviceInstance); } return tapConnect; }
private TapModify getTapModifyRequest(final String tapName, final int swIndex, final PhysAddress mac, final Long deviceInstance) { final TapModify tapConnect = new TapModify(); tapConnect.tapName = tapName.getBytes(); tapConnect.swIfIndex = swIndex; if(mac == null) { tapConnect.useRandomMac = 1; tapConnect.macAddress = new byte[6]; } else { tapConnect.useRandomMac = 0; tapConnect.macAddress = TranslateUtils.parseMac(mac.getValue()); } if(deviceInstance == null) { tapConnect.renumber = 0; } else { tapConnect.renumber = 1; tapConnect.customDevInstance = Math.toIntExact(deviceInstance); } return tapConnect; }
private TapModify getTapModifyRequest(final String tapName, final int swIndex, final PhysAddress mac, final Long deviceInstance) { final TapModify tapConnect = new TapModify(); tapConnect.tapName = tapName.getBytes(); tapConnect.swIfIndex = swIndex; if (mac == null) { tapConnect.useRandomMac = 1; tapConnect.macAddress = new byte[6]; } else { tapConnect.useRandomMac = 0; tapConnect.macAddress = parseMac(mac.getValue()); } if (deviceInstance == null) { tapConnect.renumber = 0; } else { tapConnect.renumber = 1; tapConnect.customDevInstance = Math.toIntExact(deviceInstance); } return tapConnect; }
/** * Removes the given MAC Addresses from the specified External Device. * * @param deviceNodeId * the device node id * @param macAddresses * the mac addresses * @return the listenable future */ private ListenableFuture<Void> removeRemoteUcastMacsFromExternalDevice(String deviceNodeId, String logicalSwitchName, List<PhysAddress> macAddresses) { NodeId nodeId = new NodeId(deviceNodeId); // TODO (eperefr) List<MacAddress> lstMac = Lists.transform(macAddresses, physAddress -> physAddress != null ? new MacAddress(physAddress.getValue()) : null); return HwvtepUtils.deleteRemoteUcastMacs(broker, nodeId, logicalSwitchName, lstMac); }
@Override protected Object doExecute() throws Exception { LOG.debug("Executing updating ElanInterface command" + "\t"); Collection<MacEntry> macTables = elanProvider.getElanMacTable(elanName); if (!macTables.isEmpty()) { SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy:HH:mm:ss"); session.getConsole().println(getMacTableHeaderOutput()); session.getConsole().println(elanName); for (MacEntry mac : macTables) { boolean isStatic = mac.isIsStaticAddress(); session.getConsole().println(String.format(ElanCLIUtils.MAC_TABLE_CLI_FORMAT, "", mac.getInterface(), mac.getMacAddress().getValue(), "")); session.getConsole().println(String.format(ElanCLIUtils.MAC_TABLE_CLI_FORMAT, "", isStatic, "", isStatic ? "-" : formatter.format(new Date(mac.getControllerLearnedForwardingEntryTimestamp().longValue())))); } } return null; }
private AfPacketCreate getCreateRequest(@Nonnull final AfPacket afPacket) { final AfPacketCreate request = new AfPacketCreate(); checkArgument(afPacket.getHostInterfaceName() != null, "host-interface-name is mandatory for af-packet interface"); request.hostIfName = afPacket.getHostInterfaceName().getBytes(StandardCharsets.UTF_8); checkArgument(request.hostIfName.length <= 64, "Interface name for af_packet interface should not be longer than 64 bytes, but was %s", request.hostIfName.length); final PhysAddress mac = afPacket.getMac(); if (mac == null) { request.useRandomHwAddr = 1; request.hwAddr = new byte[6]; } else { request.useRandomHwAddr = 0; request.hwAddr = parseMac(mac.getValue()); } return request; }
private ImmutablePair<BigInteger, String> getDpnIdPhysicalAddressFromInterfaceName(String interfaceName) { ImmutablePair<BigInteger, String> pair = localCache.get(interfaceName); if (pair!=null && pair.getLeft() != null && pair.getRight() != null) { return pair; } NodeConnectorId nodeConnectorId = null; org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState = getInterfaceStateFromOperDS(interfaceName); if(interfaceState != null) { List<String> ofportIds = interfaceState.getLowerLayerIf(); nodeConnectorId = new NodeConnectorId(ofportIds.get(0)); } BigInteger dpId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId)); String phyAddress = interfaceState==null ? "":interfaceState.getPhysAddress().getValue(); pair = new ImmutablePair<BigInteger, String>(dpId, phyAddress); localCache.put(interfaceName, pair); return null; } }
private void removeTheMacFlowInTheDPN(BigInteger dpId, long elanTag, BigInteger currentDpId, MacEntry mac) { mdsalManager .removeFlow(dpId, MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE, ElanUtils.getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, dpId, currentDpId, mac.getMacAddress().getValue(), elanTag))); }
private TapConnect getTapConnectRequest(final Tap tap) { final TapConnect tapConnect = new TapConnect(); tapConnect.tapName = tap.getTapName().getBytes(); final PhysAddress mac = tap.getMac(); if (mac == null) { tapConnect.useRandomMac = 1; tapConnect.macAddress = new byte[6]; } else { tapConnect.useRandomMac = 0; tapConnect.macAddress = parseMac(mac.getValue()); } final Long deviceInstance = tap.getDeviceInstance(); if (deviceInstance == null) { tapConnect.renumber = 0; } else { tapConnect.renumber = 1; tapConnect.customDevInstance = Math.toIntExact(deviceInstance); } final String tag = tap.getTag(); if (tag != null) { tapConnect.tag = tag.getBytes(StandardCharsets.US_ASCII); } return tapConnect; }
private void createLoopback(final InstanceIdentifier<Loopback> id, final String swIfName, final Loopback loopback, final WriteContext writeContext) throws WriteFailedException { LOG.debug("Setting loopback interface: {}. Loopback: {}", swIfName, loopback); final CreateLoopback createLoopback = new CreateLoopback(); if (loopback.getMac() != null) { createLoopback.macAddress = parseMac(loopback.getMac().getValue()); } final CreateLoopbackReply reply = getReplyForCreate(getFutureJVpp().createLoopback(createLoopback).toCompletableFuture(), id, loopback); LOG.debug("Loopback set successfully for: {}, loopback: {}", swIfName, loopback); // Add new interface to our interface context interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext()); }
private TapCreateV2 getTapV2CreateRequest(final TapV2 tapv2) { final TapCreateV2 tapConnect = new TapCreateV2(); final PhysAddress mac = tapv2.getMac(); if (mac == null) { tapConnect.useRandomMac = 1; tapConnect.macAddress = new byte[6]; } else { tapConnect.useRandomMac = 0; tapConnect.macAddress = parseMac(mac.getValue()); } final Integer rxRingSz = tapv2.getRxRingSize(); if (rxRingSz != null) { tapConnect.rxRingSz = rxRingSz.shortValue(); } final Integer txRingSz = tapv2.getTxRingSize(); if (txRingSz != null) { tapConnect.txRingSz = txRingSz.shortValue(); } final String tag = tapv2.getTag(); if (tag != null) { tapConnect.tag = tag.getBytes(StandardCharsets.US_ASCII); } setHostProperties(tapConnect, tapv2); return tapConnect; }
@Override public void flushMACTable(String elanInstanceName) { Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName); if (elanInfo == null) { return; } List<String> elanInterfaces = elanInfo.getElanInterfaces(); if (elanInterfaces == null || elanInterfaces.isEmpty()) { return; } for (String elanInterface : elanInterfaces) { ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(elanInterface); if (elanInterfaceMac.getMacEntry() != null && elanInterfaceMac.getMacEntry().size() > 0) { List<MacEntry> macEntries = elanInterfaceMac.getMacEntry(); for (MacEntry macEntry : macEntries) { try { deleteStaticMacAddress(elanInstanceName, elanInterface, macEntry.getMacAddress().getValue()); } catch (MacNotFoundException e) { LOG.error("Mac Not Found Exception {}", e); } } } } }
private BdIpMacAddDel createRequest(final ArpTerminationTableEntry entry, final int bdId, boolean isAdd) { final BdIpMacAddDel request = new BdIpMacAddDel(); request.bdId = bdId; request.isAdd = booleanToByte(isAdd); request.macAddress = TranslateUtils.parseMac(entry.getPhysAddress().getValue()); final IpAddress ipAddress = entry.getIpAddress(); if (ipAddress.getIpv6Address() != null) { // FIXME: vpp does not support ipv6 in arp-termination table (based on analysis of l2_bd.c) throw new UnsupportedOperationException("IPv6 address for ARP termination table is not supported yet"); } request.ipAddress = TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(ipAddress.getIpv4Address())); return request; } }
private void addDelNeighbourAndReply(InstanceIdentifier<Neighbor> id, boolean add, int parentInterfaceIndex, Neighbor data) throws VppBaseCallException, WriteTimeoutException { IpNeighborAddDel request = new IpNeighborAddDel(); request.isAdd = TranslateUtils.booleanToByte(add); request.isIpv6 = 0; request.isStatic = 1; request.dstAddress = TranslateUtils.ipv4AddressNoZoneToArray(data.getIp()); request.macAddress = TranslateUtils.parseMac(data.getLinkLayerAddress().getValue()); request.swIfIndex = parentInterfaceIndex; //TODO if it is necessary for future use ,make adjustments to be able to set vrfid //request.vrfId TranslateUtils.getReplyForWrite(getFutureJVpp().ipNeighborAddDel(request).toCompletableFuture(), id); } }
private BdIpMacAddDel createRequest(final ArpTerminationTableEntry entry, final int bdId, boolean isAdd) { final BdIpMacAddDel request = new BdIpMacAddDel(); request.bdId = bdId; request.isAdd = booleanToByte(isAdd); request.macAddress = parseMac(entry.getPhysAddress().getValue()); final IpAddressNoZone ipAddress = entry.getIpAddress(); request.ipAddress = ipAddressToArray(ipAddress); request.isIpv6 = booleanToByte(isIpv6(ipAddress)); return request; } }
private L2FibAddDel createL2FibRequest(final L2FibEntry entry, final int bdId, final int swIfIndex, boolean isAdd) { final L2FibAddDel request = new L2FibAddDel(); request.mac = macToLong(entry.getPhysAddress().getValue()); request.bdId = bdId; request.swIfIndex = swIfIndex; request.isAdd = booleanToByte(isAdd); if (isAdd) { request.staticMac = booleanToByte(entry.isStaticConfig()); request.filterMac = booleanToByte(L2FibFilter.class == entry.getAction()); } return request; }
private L2FibAddDel createL2FibRequest(final L2FibEntry entry, final int bdId, final int swIfIndex, boolean isAdd) { final L2FibAddDel request = new L2FibAddDel(); request.mac = parseMac(entry.getPhysAddress().getValue()); request.bdId = bdId; request.swIfIndex = swIfIndex; request.isAdd = booleanToByte(isAdd); if (isAdd) { request.staticMac = booleanToByte(entry.isStaticConfig()); request.filterMac = booleanToByte(L2FibFilter.class == entry.getAction()); } return request; } }
public void installDMacAddressTables(ElanInstance elanInfo, InterfaceInfo interfaceInfo, BigInteger dstDpId) throws ElanException { String interfaceName = interfaceInfo.getInterfaceName(); ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(interfaceName); if (elanInterfaceMac != null && elanInterfaceMac.getMacEntry() != null) { WriteTransaction writeFlowTx = broker.newWriteOnlyTransaction(); List<MacEntry> macEntries = elanInterfaceMac.getMacEntry(); for (MacEntry macEntry : macEntries) { PhysAddress physAddress = macEntry.getMacAddress(); elanUtils.setupDMacFlowonRemoteDpn(elanInfo, interfaceInfo, dstDpId, physAddress.getValue(), writeFlowTx); } writeFlowTx.submit(); } }