Committed by
Gerrit Code Review
BGP routepolicy distribution bug fixes.
Change-Id: I2176e3872391658263d6817ac8850a3390de00de
Showing
8 changed files
with
25 additions
and
16 deletions
... | @@ -241,13 +241,12 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg { | ... | @@ -241,13 +241,12 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg { |
241 | afi = mpUnReach.afi(); | 241 | afi = mpUnReach.afi(); |
242 | safi = mpUnReach.safi(); | 242 | safi = mpUnReach.safi(); |
243 | } | 243 | } |
244 | + } | ||
244 | 245 | ||
245 | - if ((afi == Constants.AFI_FLOWSPEC_VALUE) && ((safi == Constants.SAFI_FLOWSPEC_VALUE) | 246 | + if ((afi == Constants.AFI_FLOWSPEC_VALUE) || (afi == Constants.AFI_VALUE)) { |
246 | - || (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE))) { | ||
247 | //unfeasible route length | 247 | //unfeasible route length |
248 | cb.writeShort(0); | 248 | cb.writeShort(0); |
249 | } | 249 | } |
250 | - } | ||
251 | 250 | ||
252 | } | 251 | } |
253 | 252 | ... | ... |
... | @@ -171,6 +171,7 @@ public class As4Path implements BgpValueType { | ... | @@ -171,6 +171,7 @@ public class As4Path implements BgpValueType { |
171 | if ((as4pathSet != null) && (as4pathSeq != null)) { | 171 | if ((as4pathSet != null) && (as4pathSeq != null)) { |
172 | int iAsLenIndex = cb.writerIndex(); | 172 | int iAsLenIndex = cb.writerIndex(); |
173 | cb.writeByte(0); | 173 | cb.writeByte(0); |
174 | + if (as4pathSeq.size() != 0) { | ||
174 | cb.writeByte(AsPath.ASPATH_SEQ_TYPE); | 175 | cb.writeByte(AsPath.ASPATH_SEQ_TYPE); |
175 | cb.writeByte(as4pathSeq.size()); | 176 | cb.writeByte(as4pathSeq.size()); |
176 | 177 | ||
... | @@ -180,6 +181,7 @@ public class As4Path implements BgpValueType { | ... | @@ -180,6 +181,7 @@ public class As4Path implements BgpValueType { |
180 | 181 | ||
181 | int asLen = cb.writerIndex() - iAsLenIndex; | 182 | int asLen = cb.writerIndex() - iAsLenIndex; |
182 | cb.setByte(iAsLenIndex, (byte) (asLen - 1)); | 183 | cb.setByte(iAsLenIndex, (byte) (asLen - 1)); |
184 | + } | ||
183 | } else { | 185 | } else { |
184 | cb.writeByte(0); | 186 | cb.writeByte(0); |
185 | } | 187 | } | ... | ... |
... | @@ -208,15 +208,16 @@ public class AsPath implements BgpValueType { | ... | @@ -208,15 +208,16 @@ public class AsPath implements BgpValueType { |
208 | if (isaspathSet()) { | 208 | if (isaspathSet()) { |
209 | int iAsLenIndex = cb.writerIndex(); | 209 | int iAsLenIndex = cb.writerIndex(); |
210 | cb.writeByte(0); | 210 | cb.writeByte(0); |
211 | + if (aspathSeq.size() != 0) { | ||
211 | cb.writeByte(ASPATH_SEQ_TYPE); | 212 | cb.writeByte(ASPATH_SEQ_TYPE); |
212 | cb.writeByte(aspathSeq.size()); | 213 | cb.writeByte(aspathSeq.size()); |
213 | 214 | ||
214 | for (int j = 0; j < aspathSeq.size(); j++) { | 215 | for (int j = 0; j < aspathSeq.size(); j++) { |
215 | cb.writeShort(aspathSeq.get(j)); | 216 | cb.writeShort(aspathSeq.get(j)); |
216 | } | 217 | } |
217 | - | ||
218 | int asLen = cb.writerIndex() - iAsLenIndex; | 218 | int asLen = cb.writerIndex() - iAsLenIndex; |
219 | cb.setByte(iAsLenIndex, (byte) (asLen - 1)); | 219 | cb.setByte(iAsLenIndex, (byte) (asLen - 1)); |
220 | + } | ||
220 | } else { | 221 | } else { |
221 | cb.writeByte(0); | 222 | cb.writeByte(0); |
222 | } | 223 | } | ... | ... |
... | @@ -163,7 +163,6 @@ public class WideCommunityAttrHeader implements BgpValueType { | ... | @@ -163,7 +163,6 @@ public class WideCommunityAttrHeader implements BgpValueType { |
163 | c.writeShort(TYPE); | 163 | c.writeShort(TYPE); |
164 | c.writeByte(flag); | 164 | c.writeByte(flag); |
165 | c.writeByte(hopCount); | 165 | c.writeByte(hopCount); |
166 | - c.writeShort(length); | ||
167 | return c.writerIndex() - iLenStartIndex; | 166 | return c.writerIndex() - iLenStartIndex; |
168 | } | 167 | } |
169 | 168 | ... | ... |
... | @@ -97,8 +97,8 @@ public class WideCommunityIpV4Neighbour implements BgpValueType { | ... | @@ -97,8 +97,8 @@ public class WideCommunityIpV4Neighbour implements BgpValueType { |
97 | while (listIterator.hasNext()) { | 97 | while (listIterator.hasNext()) { |
98 | IpV4Neighbour speaker = listIterator.next(); | 98 | IpV4Neighbour speaker = listIterator.next(); |
99 | if (speaker instanceof IpV4Neighbour) { | 99 | if (speaker instanceof IpV4Neighbour) { |
100 | - c.writeInt(Integer.valueOf(speaker.localSpeaker.toString())); | 100 | + c.writeBytes(speaker.localSpeaker().toOctets()); |
101 | - c.writeInt(Integer.valueOf(speaker.remoteSpeaker.toString())); | 101 | + c.writeBytes(speaker.remoteSpeaker().toOctets()); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ... | ... |
... | @@ -43,10 +43,10 @@ import java.util.Objects; | ... | @@ -43,10 +43,10 @@ import java.util.Objects; |
43 | public class WideCommunity implements BgpValueType { | 43 | public class WideCommunity implements BgpValueType { |
44 | 44 | ||
45 | private static final Logger log = LoggerFactory.getLogger(WideCommunity.class); | 45 | private static final Logger log = LoggerFactory.getLogger(WideCommunity.class); |
46 | - public static final byte TYPE = (byte) 254; /* TODO: IANA Assigned */ | 46 | + public static final byte TYPE = (byte) 129; |
47 | public static final short LENGTH = 4; | 47 | public static final short LENGTH = 4; |
48 | public static final byte TYPE_LENGTH_SIZE = 3; | 48 | public static final byte TYPE_LENGTH_SIZE = 3; |
49 | - public static final byte FLAGS = (byte) 0x40; | 49 | + public static final byte FLAGS = (byte) 0x90; |
50 | private WideCommunityAttrHeader wideCommunityHeader; | 50 | private WideCommunityAttrHeader wideCommunityHeader; |
51 | private int community; | 51 | private int community; |
52 | private int localAsn; | 52 | private int localAsn; |
... | @@ -238,6 +238,9 @@ public class WideCommunity implements BgpValueType { | ... | @@ -238,6 +238,9 @@ public class WideCommunity implements BgpValueType { |
238 | 238 | ||
239 | wideCommunityHeader.write(c); | 239 | wideCommunityHeader.write(c); |
240 | 240 | ||
241 | + int iComLengthIndex = c.writerIndex(); | ||
242 | + c.writeShort(0); | ||
243 | + | ||
241 | c.writeInt(community); | 244 | c.writeInt(community); |
242 | c.writeInt(localAsn); | 245 | c.writeInt(localAsn); |
243 | c.writeInt(contextAsn); | 246 | c.writeInt(contextAsn); |
... | @@ -275,6 +278,9 @@ public class WideCommunity implements BgpValueType { | ... | @@ -275,6 +278,9 @@ public class WideCommunity implements BgpValueType { |
275 | c.setShort(iTargetLenIndex, (short) (length - 2)); | 278 | c.setShort(iTargetLenIndex, (short) (length - 2)); |
276 | } | 279 | } |
277 | 280 | ||
281 | + length = c.writerIndex() - iComLengthIndex; | ||
282 | + c.setShort(iComLengthIndex, (short) (length - 2)); | ||
283 | + | ||
278 | length = c.writerIndex() - iLengthIndex; | 284 | length = c.writerIndex() - iLengthIndex; |
279 | c.setShort(iLengthIndex, (short) (length - 2)); | 285 | c.setShort(iLengthIndex, (short) (length - 2)); |
280 | 286 | ... | ... |
... | @@ -135,7 +135,7 @@ public class BgpLocalRibImpl implements BgpLocalRib { | ... | @@ -135,7 +135,7 @@ public class BgpLocalRibImpl implements BgpLocalRib { |
135 | BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo(); | 135 | BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo(); |
136 | // Compare local RIB entry with the current attribute | 136 | // Compare local RIB entry with the current attribute |
137 | decisionResult = selectionAlgo.compare(nodeTree.get(nodeLsIdentifier), detailsLocRib); | 137 | decisionResult = selectionAlgo.compare(nodeTree.get(nodeLsIdentifier), detailsLocRib); |
138 | - if (decisionResult < 0) { | 138 | + if (decisionResult <= 0) { |
139 | for (BgpNodeListener l : bgpController.listener()) { | 139 | for (BgpNodeListener l : bgpController.listener()) { |
140 | l.addNode((BgpNodeLSNlriVer4) nlri, details); | 140 | l.addNode((BgpNodeLSNlriVer4) nlri, details); |
141 | } | 141 | } |
... | @@ -155,7 +155,7 @@ public class BgpLocalRibImpl implements BgpLocalRib { | ... | @@ -155,7 +155,7 @@ public class BgpLocalRibImpl implements BgpLocalRib { |
155 | BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo(); | 155 | BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo(); |
156 | // Compare local RIB entry with the current attribute | 156 | // Compare local RIB entry with the current attribute |
157 | decisionResult = selectionAlgo.compare(linkTree.get(linkLsIdentifier), detailsLocRib); | 157 | decisionResult = selectionAlgo.compare(linkTree.get(linkLsIdentifier), detailsLocRib); |
158 | - if (decisionResult < 0) { | 158 | + if (decisionResult <= 0) { |
159 | linkTree.replace(linkLsIdentifier, detailsLocRib); | 159 | linkTree.replace(linkLsIdentifier, detailsLocRib); |
160 | for (BgpLinkListener l : bgpController.linkListener()) { | 160 | for (BgpLinkListener l : bgpController.linkListener()) { |
161 | l.addLink((BgpLinkLsNlriVer4) nlri, details); | 161 | l.addLink((BgpLinkLsNlriVer4) nlri, details); |
... | @@ -175,7 +175,7 @@ public class BgpLocalRibImpl implements BgpLocalRib { | ... | @@ -175,7 +175,7 @@ public class BgpLocalRibImpl implements BgpLocalRib { |
175 | BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo(); | 175 | BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo(); |
176 | // Compare local RIB entry with the current attribute | 176 | // Compare local RIB entry with the current attribute |
177 | decisionResult = selectionAlgo.compare(prefixTree.get(prefixIdentifier), detailsLocRib); | 177 | decisionResult = selectionAlgo.compare(prefixTree.get(prefixIdentifier), detailsLocRib); |
178 | - if (decisionResult < 0) { | 178 | + if (decisionResult <= 0) { |
179 | prefixTree.replace(prefixIdentifier, detailsLocRib); | 179 | prefixTree.replace(prefixIdentifier, detailsLocRib); |
180 | log.debug("Local RIB update prefix: {}", detailsLocRib.toString()); | 180 | log.debug("Local RIB update prefix: {}", detailsLocRib.toString()); |
181 | } | 181 | } | ... | ... |
... | @@ -168,7 +168,7 @@ public class BgpPeerImpl implements BgpPeer { | ... | @@ -168,7 +168,7 @@ public class BgpPeerImpl implements BgpPeer { |
168 | 168 | ||
169 | List<BgpValueType> attributesList = new LinkedList<>(); | 169 | List<BgpValueType> attributesList = new LinkedList<>(); |
170 | byte sessionType = sessionInfo.isIbgpSession() ? (byte) 0 : (byte) 1; | 170 | byte sessionType = sessionInfo.isIbgpSession() ? (byte) 0 : (byte) 1; |
171 | - byte sAfi = Constants.VPN_SAFI_FLOWSPEC_VALUE; | 171 | + byte sAfi = Constants.SAFI_FLOWSPEC_VALUE; |
172 | 172 | ||
173 | boolean isFsCapabilitySet = isCapabilitySupported(MultiProtocolExtnCapabilityTlv.TYPE, | 173 | boolean isFsCapabilitySet = isCapabilitySupported(MultiProtocolExtnCapabilityTlv.TYPE, |
174 | Constants.AFI_FLOWSPEC_VALUE, | 174 | Constants.AFI_FLOWSPEC_VALUE, |
... | @@ -191,10 +191,10 @@ public class BgpPeerImpl implements BgpPeer { | ... | @@ -191,10 +191,10 @@ public class BgpPeerImpl implements BgpPeer { |
191 | return; | 191 | return; |
192 | } | 192 | } |
193 | 193 | ||
194 | - if ((wideCommunity != null) && (isVpnRpdCapabilitySet)) { | 194 | + if (isVpnFsCapabilitySet) { |
195 | - sAfi = Constants.VPN_SAFI_FLOWSPEC_RDP_VALUE; | ||
196 | - } else if (isVpnFsCapabilitySet) { | ||
197 | sAfi = Constants.VPN_SAFI_FLOWSPEC_VALUE; | 195 | sAfi = Constants.VPN_SAFI_FLOWSPEC_VALUE; |
196 | + } else if (isVpnRpdCapabilitySet) { | ||
197 | + sAfi = Constants.VPN_SAFI_FLOWSPEC_RDP_VALUE; | ||
198 | } | 198 | } |
199 | attributesList.add(new Origin((byte) 0)); | 199 | attributesList.add(new Origin((byte) 0)); |
200 | 200 | ||
... | @@ -223,7 +223,9 @@ public class BgpPeerImpl implements BgpPeer { | ... | @@ -223,7 +223,9 @@ public class BgpPeerImpl implements BgpPeer { |
223 | } | 223 | } |
224 | 224 | ||
225 | attributesList.add(new BgpExtendedCommunity(flowSpec.fsActionTlv())); | 225 | attributesList.add(new BgpExtendedCommunity(flowSpec.fsActionTlv())); |
226 | + if (wideCommunity != null) { | ||
226 | attributesList.add(wideCommunity); | 227 | attributesList.add(wideCommunity); |
228 | + } | ||
227 | 229 | ||
228 | if (operType == FlowSpecOperation.ADD) { | 230 | if (operType == FlowSpecOperation.ADD) { |
229 | attributesList.add(new MpReachNlri(flowSpec, Constants.AFI_FLOWSPEC_VALUE, sAfi)); | 231 | attributesList.add(new MpReachNlri(flowSpec, Constants.AFI_FLOWSPEC_VALUE, sAfi)); | ... | ... |
-
Please register or login to post a comment