mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-14 17:01:02 +02:00
ONOS-783 Update PeerConnectivityManager to handle IPv6.
Change-Id: I0c8558cec2f7fa5f772cc126c6b74e5d4531676b
This commit is contained in:
parent
2bb988bf72
commit
6e2ee15aa2
@ -21,7 +21,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.onlab.packet.Ethernet;
|
import org.onlab.packet.Ethernet;
|
||||||
import org.onlab.packet.IPv4;
|
import org.onlab.packet.IPv4;
|
||||||
|
import org.onlab.packet.IPv6;
|
||||||
import org.onlab.packet.IpAddress;
|
import org.onlab.packet.IpAddress;
|
||||||
|
import org.onlab.packet.Ip4Address;
|
||||||
import org.onlab.packet.IpPrefix;
|
import org.onlab.packet.IpPrefix;
|
||||||
import org.onosproject.core.ApplicationId;
|
import org.onosproject.core.ApplicationId;
|
||||||
import org.onosproject.net.ConnectPoint;
|
import org.onosproject.net.ConnectPoint;
|
||||||
@ -164,13 +166,28 @@ public class PeerConnectivityManager {
|
|||||||
IpAddress bgpdPeerAddress = bgpPeer.ipAddress();
|
IpAddress bgpdPeerAddress = bgpPeer.ipAddress();
|
||||||
ConnectPoint bgpdPeerConnectPoint = peerInterface.connectPoint();
|
ConnectPoint bgpdPeerConnectPoint = peerInterface.connectPoint();
|
||||||
|
|
||||||
|
if (bgpdAddress.version() != bgpdPeerAddress.version()) {
|
||||||
|
return intents;
|
||||||
|
}
|
||||||
|
|
||||||
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
|
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
TrafficSelector selector;
|
TrafficSelector selector;
|
||||||
|
|
||||||
|
byte tcpProtocol;
|
||||||
|
byte icmpProtocol;
|
||||||
|
|
||||||
|
if (bgpdAddress.version() == Ip4Address.VERSION) {
|
||||||
|
tcpProtocol = IPv4.PROTOCOL_TCP;
|
||||||
|
icmpProtocol = IPv4.PROTOCOL_ICMP;
|
||||||
|
} else {
|
||||||
|
tcpProtocol = IPv6.PROTOCOL_TCP;
|
||||||
|
icmpProtocol = IPv6.PROTOCOL_ICMP6;
|
||||||
|
}
|
||||||
|
|
||||||
// Path from BGP speaker to BGP peer matching destination TCP port 179
|
// Path from BGP speaker to BGP peer matching destination TCP port 179
|
||||||
selector = buildSelector(IPv4.PROTOCOL_TCP,
|
selector = buildSelector(tcpProtocol,
|
||||||
bgpdAddress,
|
bgpdAddress,
|
||||||
bgpdPeerAddress,
|
bgpdPeerAddress,
|
||||||
null,
|
null,
|
||||||
@ -180,7 +197,7 @@ public class PeerConnectivityManager {
|
|||||||
bgpdConnectPoint, bgpdPeerConnectPoint));
|
bgpdConnectPoint, bgpdPeerConnectPoint));
|
||||||
|
|
||||||
// Path from BGP speaker to BGP peer matching source TCP port 179
|
// Path from BGP speaker to BGP peer matching source TCP port 179
|
||||||
selector = buildSelector(IPv4.PROTOCOL_TCP,
|
selector = buildSelector(tcpProtocol,
|
||||||
bgpdAddress,
|
bgpdAddress,
|
||||||
bgpdPeerAddress,
|
bgpdPeerAddress,
|
||||||
(short) BgpConstants.BGP_PORT,
|
(short) BgpConstants.BGP_PORT,
|
||||||
@ -190,7 +207,7 @@ public class PeerConnectivityManager {
|
|||||||
bgpdConnectPoint, bgpdPeerConnectPoint));
|
bgpdConnectPoint, bgpdPeerConnectPoint));
|
||||||
|
|
||||||
// Path from BGP peer to BGP speaker matching destination TCP port 179
|
// Path from BGP peer to BGP speaker matching destination TCP port 179
|
||||||
selector = buildSelector(IPv4.PROTOCOL_TCP,
|
selector = buildSelector(tcpProtocol,
|
||||||
bgpdPeerAddress,
|
bgpdPeerAddress,
|
||||||
bgpdAddress,
|
bgpdAddress,
|
||||||
null,
|
null,
|
||||||
@ -200,7 +217,7 @@ public class PeerConnectivityManager {
|
|||||||
bgpdPeerConnectPoint, bgpdConnectPoint));
|
bgpdPeerConnectPoint, bgpdConnectPoint));
|
||||||
|
|
||||||
// Path from BGP peer to BGP speaker matching source TCP port 179
|
// Path from BGP peer to BGP speaker matching source TCP port 179
|
||||||
selector = buildSelector(IPv4.PROTOCOL_TCP,
|
selector = buildSelector(tcpProtocol,
|
||||||
bgpdPeerAddress,
|
bgpdPeerAddress,
|
||||||
bgpdAddress,
|
bgpdAddress,
|
||||||
(short) BgpConstants.BGP_PORT,
|
(short) BgpConstants.BGP_PORT,
|
||||||
@ -210,7 +227,7 @@ public class PeerConnectivityManager {
|
|||||||
bgpdPeerConnectPoint, bgpdConnectPoint));
|
bgpdPeerConnectPoint, bgpdConnectPoint));
|
||||||
|
|
||||||
// ICMP path from BGP speaker to BGP peer
|
// ICMP path from BGP speaker to BGP peer
|
||||||
selector = buildSelector(IPv4.PROTOCOL_ICMP,
|
selector = buildSelector(icmpProtocol,
|
||||||
bgpdAddress,
|
bgpdAddress,
|
||||||
bgpdPeerAddress,
|
bgpdPeerAddress,
|
||||||
null,
|
null,
|
||||||
@ -220,7 +237,7 @@ public class PeerConnectivityManager {
|
|||||||
bgpdConnectPoint, bgpdPeerConnectPoint));
|
bgpdConnectPoint, bgpdPeerConnectPoint));
|
||||||
|
|
||||||
// ICMP path from BGP peer to BGP speaker
|
// ICMP path from BGP peer to BGP speaker
|
||||||
selector = buildSelector(IPv4.PROTOCOL_ICMP,
|
selector = buildSelector(icmpProtocol,
|
||||||
bgpdPeerAddress,
|
bgpdPeerAddress,
|
||||||
bgpdAddress,
|
bgpdAddress,
|
||||||
null,
|
null,
|
||||||
@ -245,13 +262,25 @@ public class PeerConnectivityManager {
|
|||||||
private TrafficSelector buildSelector(byte ipProto, IpAddress srcIp,
|
private TrafficSelector buildSelector(byte ipProto, IpAddress srcIp,
|
||||||
IpAddress dstIp, Short srcTcpPort,
|
IpAddress dstIp, Short srcTcpPort,
|
||||||
Short dstTcpPort) {
|
Short dstTcpPort) {
|
||||||
TrafficSelector.Builder builder = DefaultTrafficSelector.builder()
|
TrafficSelector.Builder builder = null;
|
||||||
.matchEthType(Ethernet.TYPE_IPV4)
|
|
||||||
.matchIPProtocol(ipProto)
|
if (dstIp.version() == Ip4Address.VERSION) {
|
||||||
.matchIPSrc(IpPrefix.valueOf(srcIp,
|
builder = DefaultTrafficSelector.builder()
|
||||||
IpPrefix.MAX_INET_MASK_LENGTH))
|
.matchEthType(Ethernet.TYPE_IPV4)
|
||||||
.matchIPDst(IpPrefix.valueOf(dstIp,
|
.matchIPProtocol(ipProto)
|
||||||
IpPrefix.MAX_INET_MASK_LENGTH));
|
.matchIPSrc(IpPrefix.valueOf(srcIp,
|
||||||
|
IpPrefix.MAX_INET_MASK_LENGTH))
|
||||||
|
.matchIPDst(IpPrefix.valueOf(dstIp,
|
||||||
|
IpPrefix.MAX_INET_MASK_LENGTH));
|
||||||
|
} else {
|
||||||
|
builder = DefaultTrafficSelector.builder()
|
||||||
|
.matchEthType(Ethernet.TYPE_IPV6)
|
||||||
|
.matchIPProtocol(ipProto)
|
||||||
|
.matchIPv6Src(IpPrefix.valueOf(srcIp,
|
||||||
|
IpPrefix.MAX_INET6_MASK_LENGTH))
|
||||||
|
.matchIPv6Dst(IpPrefix.valueOf(dstIp,
|
||||||
|
IpPrefix.MAX_INET6_MASK_LENGTH));
|
||||||
|
}
|
||||||
|
|
||||||
if (srcTcpPort != null) {
|
if (srcTcpPort != null) {
|
||||||
builder.matchTcpSrc(srcTcpPort);
|
builder.matchTcpSrc(srcTcpPort);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user