use of org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails in project onos by opennetworkinglab.
the class BgpLocalRibImpl method localRibUpdatePrefix.
/**
* Update localRIB prefix based on available peer adjacency RIB.
*
* @param o instance of adjacency-in/VPN adjacency-in
* @throws BgpParseException BGP parse exception
*/
public void localRibUpdatePrefix(Object o) throws BgpParseException {
if (o instanceof AdjRibIn) {
AdjRibIn adjRib = (AdjRibIn) o;
log.debug("Update local RIB prefix.");
Set<BgpPrefixLSIdentifier> prefixKeys = adjRib.prefixTree().keySet();
for (BgpPrefixLSIdentifier key : prefixKeys) {
PathAttrNlriDetails pathAttrNlri = adjRib.prefixTree().get(key);
BgpPrefixIPv4LSNlriVer4 prefixNlri = new BgpPrefixIPv4LSNlriVer4(pathAttrNlri.identifier(), pathAttrNlri.protocolID().getType(), key, null, false);
decisionProcess(prefixNlri);
}
}
if (o instanceof VpnAdjRibIn) {
VpnAdjRibIn vpnAdjRib = (VpnAdjRibIn) o;
log.debug("Update local RIB VPN prefix.");
Set<RouteDistinguisher> prefixKeysVpn = vpnAdjRib.vpnPrefixTree().keySet();
Map<BgpPrefixLSIdentifier, PathAttrNlriDetails> prefix;
for (RouteDistinguisher keyVpnPrefix : prefixKeysVpn) {
prefix = vpnAdjRib.vpnPrefixTree().get(keyVpnPrefix);
Set<BgpPrefixLSIdentifier> vpnPrefixKeys = prefix.keySet();
for (BgpPrefixLSIdentifier key : vpnPrefixKeys) {
PathAttrNlriDetails pathAttrNlri = vpnAdjRib.prefixTree().get(key);
BgpPrefixIPv4LSNlriVer4 prefixNlri = new BgpPrefixIPv4LSNlriVer4(pathAttrNlri.identifier(), pathAttrNlri.protocolID().getType(), key, keyVpnPrefix, true);
decisionProcess(prefixNlri, keyVpnPrefix);
}
}
}
}
use of org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails in project onos by opennetworkinglab.
the class BgpLocalRibImpl method localRibUpdateLink.
/**
* Update localRIB link based on available peer adjacency RIB.
*
* @param o adjacency-in/VPN adjacency-in
* @throws BgpParseException BGP parse exceptions
*/
public void localRibUpdateLink(Object o) throws BgpParseException {
if (o instanceof AdjRibIn) {
AdjRibIn adjRib = (AdjRibIn) o;
log.debug("Update local RIB link.");
Set<BgpLinkLSIdentifier> linkKeys = adjRib.linkTree().keySet();
for (BgpLinkLSIdentifier key : linkKeys) {
PathAttrNlriDetails pathAttrNlri = adjRib.linkTree().get(key);
BgpLinkLsNlriVer4 linkNlri = new BgpLinkLsNlriVer4(pathAttrNlri.protocolID().getType(), pathAttrNlri.identifier(), key, null, false);
decisionProcess(linkNlri);
}
}
if (o instanceof VpnAdjRibIn) {
VpnAdjRibIn vpnAdjRib = (VpnAdjRibIn) o;
log.debug("Update local RIB VPN link");
Set<RouteDistinguisher> linkKeysVpn = vpnAdjRib.vpnLinkTree().keySet();
Map<BgpLinkLSIdentifier, PathAttrNlriDetails> link;
for (RouteDistinguisher keyVpnLink : linkKeysVpn) {
link = vpnAdjRib.vpnLinkTree().get(keyVpnLink);
Set<BgpLinkLSIdentifier> vpnLinkKeys = link.keySet();
for (BgpLinkLSIdentifier key : vpnLinkKeys) {
PathAttrNlriDetails pathAttrNlri = vpnAdjRib.linkTree().get(key);
BgpLinkLsNlriVer4 linkNlri = new BgpLinkLsNlriVer4(pathAttrNlri.protocolID().getType(), pathAttrNlri.identifier(), key, keyVpnLink, true);
decisionProcess(linkNlri, keyVpnLink);
}
}
}
}
use of org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails in project onos by opennetworkinglab.
the class BgpSelectionAlgoTest method selectionAlgoTest3.
/**
* firstPathAttribute and secondPathAttribute has same AS value
* and firstPathAttribute has shortest Origin value than secondPathAttribute.
*/
@Test
public void selectionAlgoTest3() throws BgpParseException {
byte[] peerIp = new byte[] { 0x0a, 0x0a, 0x0a, 0x0a };
LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
BgpValueType pathAttribute1;
byte[] origin = new byte[] { 0x40, 0x01, 0x01, 0x00 };
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute1 = Origin.read(buffer);
pathAttributes1.add(pathAttribute1);
byte[] asPath = new byte[] { 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9 };
buffer.writeBytes(asPath);
pathAttribute1 = AsPath.read(buffer);
pathAttributes1.add(pathAttribute1);
IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
int bgpId = 168427777;
short locRibAsNum = 100;
boolean isIbgp = false;
PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
attrList1.setIdentifier(0);
attrList1.setPathAttribute(pathAttributes1);
attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(ipAddress, bgpId, locRibAsNum, isIbgp, attrList1);
peerIp = new byte[] { 0x0b, 0x0b, 0x0b, 0x0b };
LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
BgpValueType pathAttribute2;
origin = new byte[] { 0x40, 0x01, 0x01, 0x02 };
buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute2 = Origin.read(buffer);
pathAttributes2.add(pathAttribute2);
asPath = new byte[] { 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9 };
buffer.writeBytes(asPath);
pathAttribute2 = AsPath.read(buffer);
pathAttributes2.add(pathAttribute2);
ipAddress = IpAddress.valueOf(Version.INET, peerIp);
bgpId = 536936448;
locRibAsNum = 200;
isIbgp = true;
PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
attrList2.setIdentifier(0);
attrList2.setPathAttribute(pathAttributes2);
attrList2.setProtocolID(ProtocolType.OSPF_V2);
PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(ipAddress, bgpId, locRibAsNum, isIbgp, attrList2);
BgpSelectionAlgo algo = new BgpSelectionAlgo();
int result = algo.compare(list1, list2);
assertThat(result, is(1));
}
use of org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails in project onos by opennetworkinglab.
the class BgpSelectionAlgoTest method selectionAlgoTest2.
/**
* firstPathAttribute has 1 AS count and secondPathAttribute has 2 AS count
* and firstPathAttribute has shortest Origin value than secondPathAttribute.
*/
@Test
public void selectionAlgoTest2() throws BgpParseException {
byte[] peerIp = new byte[] { 0x0a, 0x0a, 0x0a, 0x0a };
LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
BgpValueType pathAttribute1;
byte[] origin = new byte[] { 0x40, 0x01, 0x01, 0x00 };
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute1 = Origin.read(buffer);
pathAttributes1.add(pathAttribute1);
byte[] asPath = new byte[] { 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9 };
buffer.writeBytes(asPath);
pathAttribute1 = AsPath.read(buffer);
pathAttributes1.add(pathAttribute1);
IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
int bgpId = 168427777;
short locRibAsNum = 100;
boolean isIbgp = false;
PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
attrList1.setIdentifier(0);
attrList1.setPathAttribute(pathAttributes1);
attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(ipAddress, bgpId, locRibAsNum, isIbgp, attrList1);
peerIp = new byte[] { 0x0b, 0x0b, 0x0b, 0x0b };
LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
BgpValueType pathAttribute2;
origin = new byte[] { 0x40, 0x01, 0x01, 0x02 };
buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute2 = Origin.read(buffer);
pathAttributes2.add(pathAttribute2);
asPath = new byte[] { 0x40, 0x02, 0x08, 0x02, 0x01, (byte) 0xfd, (byte) 0xea, 0x02, 0x01, (byte) 0xfd, (byte) 0xea };
buffer.writeBytes(asPath);
pathAttribute2 = AsPath.read(buffer);
pathAttributes2.add(pathAttribute2);
ipAddress = IpAddress.valueOf(Version.INET, peerIp);
bgpId = 536936448;
locRibAsNum = 200;
isIbgp = true;
PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
attrList2.setIdentifier(0);
attrList2.setPathAttribute(pathAttributes2);
attrList2.setProtocolID(ProtocolType.OSPF_V2);
PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(ipAddress, bgpId, locRibAsNum, isIbgp, attrList2);
BgpSelectionAlgo algo = new BgpSelectionAlgo();
int result = algo.compare(list1, list2);
assertThat(result, is(-1));
}
use of org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails in project onos by opennetworkinglab.
the class BgpSelectionAlgoTest method selectionAlgoTest1.
/**
* firstPathAttribute and secondPathAttribute has same AS count and firstPathAttribute
* has shortest Origin value than secondPathAttribute.
*/
@Test
public void selectionAlgoTest1() throws BgpParseException {
byte[] peerIp = new byte[] { 0x0a, 0x0a, 0x0a, 0x0a };
LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
BgpValueType pathAttribute1;
// origin with IGP
byte[] origin = new byte[] { 0x40, 0x01, 0x01, 0x00 };
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute1 = Origin.read(buffer);
pathAttributes1.add(pathAttribute1);
// AsPath with AS_SEQ with one AS
byte[] asPath = new byte[] { 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xea };
buffer.writeBytes(asPath);
pathAttribute1 = AsPath.read(buffer);
pathAttributes1.add(pathAttribute1);
IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
int bgpId = 168427777;
short locRibAsNum = 100;
boolean isIbgp = false;
PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
attrList1.setIdentifier(0);
attrList1.setPathAttribute(pathAttributes1);
attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(ipAddress, bgpId, locRibAsNum, isIbgp, attrList1);
peerIp = new byte[] { 0x0b, 0x0b, 0x0b, 0x0b };
LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
BgpValueType pathAttribute2;
// origin with INCOMPLETE
origin = new byte[] { 0x40, 0x01, 0x01, 0x02 };
buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute2 = Origin.read(buffer);
pathAttributes2.add(pathAttribute2);
// AsPath with AS_SEQ with one AS
asPath = new byte[] { 0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9 };
buffer.writeBytes(asPath);
pathAttribute2 = AsPath.read(buffer);
pathAttributes2.add(pathAttribute2);
ipAddress = IpAddress.valueOf(Version.INET, peerIp);
bgpId = 536936448;
locRibAsNum = 200;
isIbgp = true;
PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
attrList2.setIdentifier(0);
attrList2.setPathAttribute(pathAttributes2);
attrList2.setProtocolID(ProtocolType.OSPF_V2);
PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(ipAddress, bgpId, locRibAsNum, isIbgp, attrList2);
BgpSelectionAlgo algo = new BgpSelectionAlgo();
int result = algo.compare(list1, list2);
assertThat(result, is(1));
}
Aggregations