+
+ protected Boolean installRouterFibEntries(final VrfEntry vrfEntry, final Collection<VpnToDpnList> vpnToDpnList,
+ long vpnId, int addOrRemove) {
+ RouterInterface routerInt = vrfEntry.getAugmentation(RouterInterface.class);
+ if (routerInt != null && vpnToDpnList != null) {
+ String routerId = routerInt.getUuid();
+ String macAddress = routerInt.getMacAddress();
+ String ipValue = routerInt.getIpAddress();
+ LOG.trace("createFibEntries - Router augmented vrfentry found for for router uuid:{}, ip:{}, mac:{}",
+ routerId, ipValue, macAddress);
+ for (VpnToDpnList vpnDpn : vpnToDpnList) {
+ if (vpnDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
+ installRouterFibEntry(vrfEntry, vpnDpn.getDpnId(), vpnId, routerId, ipValue,
+ new MacAddress(macAddress), addOrRemove);
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public void installRouterFibEntry(final VrfEntry vrfEntry, BigInteger dpnId, long vpnId, String routerUuid,
+ String routerInternalIp, MacAddress routerMac, int addOrRemove) {
+ String[] subSplit = routerInternalIp.split("/");
+
+ String addRemoveStr = (addOrRemove == NwConstants.ADD_FLOW) ? "ADD_FLOW" : "DELETE_FLOW";
+ LOG.trace("{}: bulding Echo Flow entity for dpid:{}, router_ip:{}, vpnId:{}, subSplit:{} ", addRemoveStr,
+ dpnId, routerInternalIp, vpnId, subSplit[0]);
+
+ List<MatchInfo> matches = new ArrayList<>();
+
+ matches.add(new MatchInfo(MatchFieldType.ip_proto, new long[] { IPProtocols.ICMP.intValue() }));
+ matches.add(new MatchInfo(MatchFieldType.metadata,
+ new BigInteger[] { MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID }));
+ matches.add(new MatchInfo(MatchFieldType.icmp_v4, new long[] { (short) 8, (short) 0 }));
+ matches.add(new MatchInfo(MatchFieldType.eth_type, new long[] { NwConstants.ETHTYPE_IPV4 }));
+ matches.add(new MatchInfo(MatchFieldType.ipv4_destination, new String[] { subSplit[0], "32" }));
+
+ List<ActionInfo> actionsInfos = new ArrayList<>();
+
+ // Set Eth Src and Eth Dst
+ actionsInfos.add(new ActionInfo(ActionType.move_src_dst_eth, new String[] {}));
+ actionsInfos.add(new ActionInfo(ActionType.set_field_eth_src, new String[] { routerMac.getValue() }));
+
+ // Move Ip Src to Ip Dst
+ actionsInfos.add(new ActionInfo(ActionType.move_src_dst_ip, new String[] {}));
+ actionsInfos.add(new ActionInfo(ActionType.set_source_ip, new String[] { subSplit[0], "32" }));
+
+ // Set the ICMP type to 0 (echo reply)
+ actionsInfos.add(new ActionInfo(ActionType.set_icmp_type, new String[] { "0" }));
+
+ actionsInfos.add(new ActionInfo(ActionType.nx_load_in_port, new BigInteger[]{ BigInteger.ZERO }));
+
+ actionsInfos.add(new ActionInfo(ActionType.nx_resubmit,
+ new String[] { Short.toString(NwConstants.L3_FIB_TABLE) }));
+
+ List<InstructionInfo> instructions = new ArrayList<>();
+
+ instructions.add(new InstructionInfo(InstructionType.apply_actions, actionsInfos));
+
+ int priority = FibConstants.DEFAULT_FIB_FLOW_PRIORITY + FibConstants.DEFAULT_PREFIX_LENGTH;
+ String flowRef = getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, vrfEntry.getLabel(), priority);
+
+ FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef,
+ 0, 0, NwConstants.COOKIE_VM_FIB_TABLE, matches, instructions);
+
+ if (addOrRemove == NwConstants.ADD_FLOW) {
+ mdsalManager.installFlow(flowEntity);
+ } else {
+ mdsalManager.removeFlow(flowEntity);
+ }
+ }