Shashikanth VH
Committed by ShashikanthVH-Huawei

BGP non root user port issue fix.

Change-Id: Ia2de9425807898f4e1e8c04f81475f77b5320c93
......@@ -47,6 +47,11 @@
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>4.0.36.Final</version>
</dependency>
</dependencies>
<build>
......
......@@ -205,7 +205,7 @@ public class BgpConfig implements BgpCfg {
lspeer.setSelfInnitConnection(true);
if (lspeer.connectPeer() == null) {
connectPeer = new BgpConnectPeerImpl(bgpController, routerid, Controller.getBgpPortNum());
connectPeer = new BgpConnectPeerImpl(bgpController, routerid, Controller.BGP_PORT_NUM);
lspeer.setConnectPeer(connectPeer);
connectPeer.connectPeer();
}
......
......@@ -159,8 +159,9 @@ public class BgpPeerImpl implements BgpPeer {
* Send flow specification update message to peer.
*
* @param operType operation type
* @param routeKey flow rule key
* @param flowSpec flow specification details
* @param wideCommunity for route policy
* @param wideCommunity for route policy
*/
public final void sendFlowSpecUpdateMessageToPeer(FlowSpecOperation operType, BgpFlowSpecRouteKey routeKey,
BgpFlowSpecNlri flowSpec, WideCommunity wideCommunity) {
......
......@@ -16,7 +16,7 @@
package org.onosproject.bgp.controller.impl;
import static org.onlab.util.Tools.groupedThreads;
import io.netty.util.internal.PlatformDependent;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.net.InetSocketAddress;
......@@ -53,9 +53,11 @@ public class Controller {
public Channel serverChannel;
// Configuration options
private static final short BGP_PORT_NUM = 179;
protected static final short BGP_PORT_NUM = 179;
private static final short BGP_PRIVILEGED_PORT = 1790; // server port used for non root users in linux
private static final short PORT_NUM_ZERO = 0;
private static boolean isPortNumSet = false;
private static short portNumber = BGP_PORT_NUM;
private final int workerThreads = 16;
private final int peerWorkerThreads = 16;
......@@ -219,6 +221,11 @@ public class Controller {
*/
public void start() {
log.info("Started");
if (!PlatformDependent.isWindows() && !PlatformDependent.isRoot()) {
portNumber = BGP_PRIVILEGED_PORT;
} else {
portNumber = BGP_PORT_NUM;
}
this.init();
this.run();
}
......@@ -242,7 +249,8 @@ public class Controller {
if (isPortNumSet) {
return PORT_NUM_ZERO;
}
return BGP_PORT_NUM;
return portNumber;
}
/**
......