import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
-
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-
import org.opendaylight.protocol.bgp.parser.BGPSession;
import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Update;
* @param msg received Update message
*/
public void updReceived(final Update msg) {
- TablesKey type = null;
- if (msg.getNlri() != null || msg.getWithdrawnRoutes() != null) {
- type = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
- } else if (msg.getPathAttributes().getAugmentation(PathAttributes1.class) != null) {
- final PathAttributes1 pa = msg.getPathAttributes().getAugmentation(PathAttributes1.class);
- if (pa.getMpReachNlri() != null) {
- type = new TablesKey(pa.getMpReachNlri().getAfi(), pa.getMpReachNlri().getSafi());
- }
- } else if (msg.getPathAttributes().getAugmentation(PathAttributes2.class) != null) {
- final PathAttributes2 pa = msg.getPathAttributes().getAugmentation(PathAttributes2.class);
- if (pa.getMpUnreachNlri() != null) {
- type = new TablesKey(pa.getMpUnreachNlri().getAfi(), pa.getMpUnreachNlri().getSafi());
+ TablesKey type = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
+ boolean isEOR = false;
+ if (msg.getNlri() == null && msg.getWithdrawnRoutes() == null) {
+ if (msg.getPathAttributes() != null) {
+ if (msg.getPathAttributes().getAugmentation(PathAttributes1.class) != null) {
+ final PathAttributes1 pa = msg.getPathAttributes().getAugmentation(PathAttributes1.class);
+ if (pa.getMpReachNlri() != null) {
+ type = new TablesKey(pa.getMpReachNlri().getAfi(), pa.getMpReachNlri().getSafi());
+ }
+ } else if (msg.getPathAttributes().getAugmentation(PathAttributes2.class) != null) {
+ final PathAttributes2 pa = msg.getPathAttributes().getAugmentation(PathAttributes2.class);
+ if (pa.getMpUnreachNlri() != null) {
+ type = new TablesKey(pa.getMpUnreachNlri().getAfi(), pa.getMpUnreachNlri().getSafi());
+ }
+ }
+ } else {
+ isEOR = true;
}
}
final SyncVariables s = this.syncStorage.get(type);
return;
}
s.setUpd(true);
+ if (isEOR) {
+ s.setEorTrue();
+ }
}
/**
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-
import java.util.Set;
-
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.protocol.bgp.parser.BGPSession;
private Update lsm;
+ private Update eorm;
+
@Before
public void setUp() {
this.listener = new SimpleSessionListener();
this.lsm = new UpdateBuilder().setPathAttributes(paBuilder.build()).build();
+ this.eorm = new UpdateBuilder().build();
+
final Set<TablesKey> types = Sets.newHashSet();
types.add(new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
types.add(new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
this.bs.kaReceived(); // ipv4 sync
assertEquals(2, this.listener.getListMsg().size());
}
+
+ @Test
+ public void testSynchronizeWithEOR() {
+ this.bs.updReceived(this.ipv4m);
+ this.bs.updReceived(this.lsm);
+ // Ipv4 Unicast synchronized by EOR message
+ this.bs.updReceived(this.eorm);
+ // Linkstate not synchronized yet
+ this.bs.kaReceived();
+ // no message sent by BGPSychchronization
+ assertEquals(0, this.listener.getListMsg().size());
+ this.bs.kaReceived();
+ assertEquals(1, this.listener.getListMsg().size());
+ assertEquals(LinkstateAddressFamily.class, ((Update) this.listener.getListMsg().get(0)).getPathAttributes().getAugmentation(
+ PathAttributes1.class).getMpReachNlri().getAfi());
+ }
}