import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.EvpnRdToNetworks;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetwork;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
private final BgpConfigurationManager bgpConfigManager;
private final BgpUtil bgpUtil;
- public EvpnRdNetworkListener(DataBroker dataBroker, BgpConfigurationManager bgpConfigManager, BgpUtil bgpUtil) {
+ public EvpnRdNetworkListener(DataBroker dataBroker, BgpConfigurationManager bgpConfigManager, BgpUtil bgpUtil,
+ final IdManagerService idManager) {
super(EvpnRdToNetwork.class, EvpnRdNetworkListener.class);
this.broker = dataBroker;
this.bgpConfigManager = bgpConfigManager;
"display routing bgp ipv4 vpn summary",
"display routing bgp ipv4 unicast <ip>",
"display routing bgp ipv4 unicast <ip/mask>",
+ "display routing bgp bfd neighbors details",
+ "display routing bgp bfd neighbors",
+ "display routing bgp bfd neighbors <ip> details",
+ "display routing bgp bfd global-config",
"display routing running-config"
};
try {
handleCommand(cmd);
} catch (IOException ioe) {
- session.getConsole().println("IOException thrown.");
+ session.getConsole().println("I/O error to" + serverName + ":"
+ + SERVER_PORT + "occured " + ioe.getMessage());
}
break;
default:
socket = new Socket(serverName, SERVER_PORT);
} catch (UnknownHostException ioe) {
- System.out.println("No host exists: " + ioe.getMessage());
+ System.out.println("No host to " + serverName + ":"
+ + SERVER_PORT + "exists: " + ioe.getMessage());
return;
} catch (IOException ioe) {
- System.out.println("I/O error occured " + ioe.getMessage());
+ System.out.println("I/O error to" + serverName + ":"
+ + SERVER_PORT + "occured " + ioe.getMessage());
return;
}
try {
inFromSocket = new BufferedReader(new InputStreamReader(socket.getInputStream()));
} catch (IOException ioe) {
- System.out.println("IOException thrown.");
+ System.out.println("I/O error to" + serverName + ":"
+ + SERVER_PORT + "occured " + ioe.getMessage());
socket.close();
return;
}
ip = inFromSocket.read();
} catch (SocketTimeoutException ste) {
System.out.println(sb.toString());
- System.out.println("Read from Socket timed Out while verifying the password.");
+ System.out.println("Socket timeout while verifying the password in" + serverName + ":"
+ + SERVER_PORT + "occured " + ste.getMessage());
socket.close();
return;
}
ip = inFromSocket.read();
} catch (SocketTimeoutException ste) {
System.out.println(sb.toString());
- System.out.println("Read from Socket timed Out while sending the term len command..");
+ System.out.println("Read from socket timeout while sending term len command in" + serverName + ":"
+ + SERVER_PORT + "occured " + ste.getMessage());
socket.close();
return;
}
String inputCmd = "show " + command;
outToSocket.println(inputCmd);
- StringBuilder output = new StringBuilder();
+ StringBuffer output = new StringBuffer();
String errorMsg = "";
while (true) {
char[] opBuf = new char[100];
} catch (SocketTimeoutException ste) {
errorMsg = "Read from Socket timed Out while getting the data.";
+ System.out.println("Socket timeout while getting the data in" + serverName + ":"
+ + SERVER_PORT + "occured " + ste.getMessage());
break;
}
if (ret == -1) {
}
- String outputStr = temp.toString().replaceAll("^\\s", "");
+ String outputStr = temp.toString();
output.append(outputStr);
if (output.toString().trim().endsWith(prompt)) {
int index = output.toString().lastIndexOf(prompt);
} else {
mintx = Integer.parseInt(minTX);
if (mintx < MIN_TX_MIN || mintx > MIN_TX_MAX) {
- ps.println("error: value of TX should be between 1000 and 60000");
+ ps.println("error: value of TX should be between 1000 and 4294000");
return null;
}
}
try {
InetAddress.getByName(nbr);
} catch (UnknownHostException e) {
- session.getConsole().println("Invalid neighbor ip");
+ session.getConsole().println("Invalid neighbor ip :" + nbr);
return null;
}
}
String BGP_COUNTER_NBR_PKTS_TX = "BgpNeighborPacketsSent";
String BGP_COUNTER_RD_ROUTE_COUNT = "BgpRdRouteCount";
String BGP_COUNTER_TOTAL_PFX = "BgpTotalPrefixes:Bgp_Total_Prefixes";
+ String BGP_COUNTER_IPV4_PFX = "BgpIPV4Prefixes:Bgp_IPV4_Prefixes";
+ String BGP_COUNTER_IPV6_PFX = "BgpIPV6Prefixes:Bgp_IPV6_Prefixes";
String BGP_DEF_LOG_LEVEL = "debugging";
String BGP_DEF_LOG_FILE = "/opt/quagga/var/log/quagga/zrpcd.init.log";
String BFD_COUNTER_NBR_PKTS_RX = "BfdNeighborPacketsReceived";
String BFD_COUNTER_NBR_PKTS_TX = "BfdNeighborPacketsSent";
long DEFAULT_ETH_TAG = 0L;
int BGP_DEFAULT_MULTIPATH = 2;
- int BFD_DEFAULT_DETECT_MULT = 3;
+ int BFD_DEFAULT_DETECT_MULT = 8;
+ String BGP_CONFIG_ENTITY = "bgp";
int BFD_DEFAULT_MIN_RX = 500;
- int BFD_DEFAULT_MIN_TX = 6000;
+ int BFD_DEFAULT_MIN_TX = 500000;
int MIN_RX_MIN = 50;
int MIN_RX_MAX = 50000;
int MIN_TX_MIN = 1000;
- int MIN_TX_MAX = 60000;
- int HISTORY_LIMIT = 10000;
- int HISTORY_THRESHOLD = 7500;
+ int MIN_TX_MAX = 4294001;
int MIN_DETECT_MULT = 2;
int MAX_DETECT_MULT = 255;
+ int HISTORY_LIMIT = 100000;
+ int HISTORY_THRESHOLD = 75000;
int BFD_DEFAULT_FAILURE_THRESHOLD = 0;
int BFD_DEFAULT_SUCCESS_THRESHOLD = 0;
}
package org.opendaylight.netvirt.bgpmanager.oam;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
public static final String BGP_EVPN_SUMMARY_FILE = "cmd_bgp_evpn_all_summary.txt";
public static final String BFD_NBR_DETAIL_FILE = "cmd_bfd_neighbors_details.txt";
+
// BFD related constants
public static final int LINE = 1; // line where the ip address of neigbor present after "NeighbroAddr"
public static final int NBR_IP_WORD_INDEX = 1; // word where the ip address is present (count start from 0)
private static final Logger LOG = LoggerFactory.getLogger(BgpCounters.class);
private final Map<String, String> totalPfxMap = new ConcurrentHashMap<>();
+ private final Map<String, String> ipv4PfxMap = new ConcurrentHashMap<>();
+ private final Map<String, String> ipv6PfxMap = new ConcurrentHashMap<>();
private final String bgpSdncMip;
private final MetricProvider metricProvider;
sb.append((char) read);
break;
}
+
}
- // Enable
- toRouter.println("en");
+ toRouter.flush();
// Wait for '#'
while ((read = fromRouter.read()) != '#') {
}
}
+
// Send the command
toRouter.println(cmdName);
+ toRouter.flush();
+
// Read all the router's output
sb = new StringBuilder();
// Store in the file
toFile.write(sb.toString().trim());
+ socket.close();
+ toFile.flush();
+ toFile.close();
+ toRouter.flush();
+ toRouter.close();
+ fromRouter.close();
} catch (UnknownHostException e) {
LOG.info("Unknown host exception occured while socket creation {} ", bgpSdncMip);
} catch (SocketTimeoutException e) {
LOG.info("Socket timeout Exception occured while socket creation");
} catch (IOException e) {
- LOG.info("I/O exception occured while socket creation");
+ LOG.error("I/O error ip {} {}",bgpSdncMip, e.getMessage());
}
}
i = processRouteCount(rd + "_VPNV4", i + 1, inputStrs);
}
}
+ long bgpIpv4Pfxs = calculateBgpIpv4Prefixes();
+ LOG.trace("BGP IPV4 Prefixes:{}",bgpIpv4Pfxs);
+ Counter counter = getCounter(BgpConstants.BGP_COUNTER_IPV4_PFX, null, null, null,
+ null, null, "bgp-peer");
+ updateCounter(counter, bgpIpv4Pfxs);
}
/*
i = processRouteCount(rd + "_VPNV6", i + 1, inputStrs);
}
}
+ long bgpIpv6Pfxs = calculateBgpIpv6Prefixes();
+ LOG.trace("BGP IPV6 Prefixes:{}",bgpIpv6Pfxs);
+ Counter counter = getCounter(BgpConstants.BGP_COUNTER_IPV6_PFX, null, null, null,
+ null, null, "bgp-peer");
+ updateCounter(counter, bgpIpv6Pfxs);
}
private void parseBgpL2vpnEvpnAll() {
String[] result = instr.split(":");
String rd = result[1].trim() + "_" + result[2].trim();
i = processRouteCount(rd + "_EVPN", i + 1, inputStrs);
+ LOG.trace("BGP Total Prefixes:{}", i);
}
}
/*populate the "BgpTotalPrefixes" counter by combining
String bgpRdRouteCountKey = BgpConstants.BGP_COUNTER_RD_ROUTE_COUNT + rd;
Counter counter = getCounter(BgpConstants.BGP_COUNTER_RD_ROUTE_COUNT, null, null, null,
null, rd, "bgp-peer");
-
for (String str = inputStrs.get(num); str != null && !str.trim().equals("")
&& num < inputStrs.size();
str = inputStrs.get(num)) {
updateCounter(counter, routeCount);
return num - 1;
}
- routeCount++;
+ else if (rd.contains("VPNV4")) {
+ ipv4PfxMap.put(bgpRdRouteCountKey, Long.toString(++routeCount));
+ updateCounter(counter, routeCount);
+ } else if (rd.contains("VPNV6")) {
+ ipv6PfxMap.put(bgpRdRouteCountKey, Long.toString(++routeCount));
+ updateCounter(counter, routeCount);
+ }
num++;
if (num == inputStrs.size()) {
break;
return num - 1;
}
+ private Long calculateBgpIpv4Prefixes() {
+ return ipv4PfxMap.entrySet().stream()
+ .map(Map.Entry::getValue).mapToLong(Long::parseLong).sum();
+ }
+
+ private Long calculateBgpIpv6Prefixes() {
+ return ipv6PfxMap.entrySet().stream()
+ .map(Map.Entry::getValue).mapToLong(Long::parseLong).sum();
+ }
+
private Long calculateBgpTotalPrefixes() {
return totalPfxMap.entrySet().stream()
.map(Map.Entry::getValue).mapToLong(Long::parseLong).sum();
private void resetCounters() {
totalPfxMap.clear();
+ ipv6PfxMap.clear();
+ ipv4PfxMap.clear();
resetFile("cmd_ip_bgp_summary.txt");
resetFile("cmd_bgp_ipv4_unicast_statistics.txt");
resetFile(BGP_VPNV4_FILE);
//moment, we just use 8 bytes more than the size of
//the C struct.
- return 96;
+ return 168;
}
public int setState(int newState) {