Jonathan Hart

BGP router now handles the case where groups don't exists right away.

Also reworked some logic to make delete routes work.

Change-Id: I1f65279284b85144a847f1295fcbd7695cb59167
......@@ -18,30 +18,59 @@ package org.onosproject.bgprouter;
import com.google.common.base.MoreObjects;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onosproject.net.group.GroupKey;
import java.util.Objects;
/**
* Created by jono on 2/12/15.
* Represents a next hop for routing, whose MAC address has already been resolved.
*/
public class NextHop {
private final IpAddress ip;
private final MacAddress mac;
private final GroupKey group;
public NextHop(IpAddress ip, MacAddress mac) {
/**
* Creates a new next hop.
*
* @param ip next hop's IP address
* @param mac next hop's MAC address
* @param group next hop's group
*/
public NextHop(IpAddress ip, MacAddress mac, GroupKey group) {
this.ip = ip;
this.mac = mac;
this.group = group;
}
/**
* Returns the next hop's IP address.
*
* @return next hop's IP address
*/
public IpAddress ip() {
return ip;
}
/**
* Returns the next hop's MAC address.
*
* @return next hop's MAC address
*/
public MacAddress mac() {
return mac;
}
/**
* Returns the next hop group.
*
* @return group
*/
public GroupKey group() {
return group;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof NextHop)) {
......@@ -51,12 +80,13 @@ public class NextHop {
NextHop that = (NextHop) o;
return Objects.equals(this.ip, that.ip) &&
Objects.equals(this.mac, that.mac);
Objects.equals(this.mac, that.mac) &&
Objects.equals(this.group, that.group);
}
@Override
public int hashCode() {
return Objects.hash(ip, mac);
return Objects.hash(ip, mac, group);
}
@Override
......@@ -64,6 +94,7 @@ public class NextHop {
return MoreObjects.toStringHelper(getClass())
.add("ip", ip)
.add("mac", mac)
.add("group", group)
.toString();
}
}
......
......@@ -24,16 +24,26 @@ import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Created by jono on 2/16/15.
* Identifier for a next hop group.
*/
public class NextHopGroupKey implements GroupKey {
private final IpAddress address;
/**
* Creates a new next hop group key.
*
* @param address next hop's IP address
*/
public NextHopGroupKey(IpAddress address) {
this.address = checkNotNull(address);
}
/**
* Returns the next hop's IP address.
*
* @return next hop's IP address
*/
public IpAddress address() {
return address;
}
......
......@@ -288,8 +288,16 @@ public class DistributedStatisticStore implements StatisticStore {
private ConnectPoint buildConnectPoint(FlowRule rule) {
PortNumber port = getOutput(rule);
boolean hasGoto = rule.treatment().instructions()
.stream()
.anyMatch(i -> (i instanceof Instructions.GroupInstruction)
|| (i instanceof Instructions.TableTypeTransition));
if (port == null) {
log.debug("Rule {} has no output.", rule);
if (!hasGoto) {
log.debug("Rule {} has no output.", rule);
}
return null;
}
ConnectPoint cp = new ConnectPoint(rule.deviceId(), port);
......
......@@ -154,8 +154,16 @@ public class SimpleStatisticStore implements StatisticStore {
private ConnectPoint buildConnectPoint(FlowRule rule) {
PortNumber port = getOutput(rule);
boolean hasGoto = rule.treatment().instructions()
.stream()
.anyMatch(i -> (i instanceof Instructions.GroupInstruction)
|| (i instanceof Instructions.TableTypeTransition));
if (port == null) {
log.debug("Rule {} has no output.", rule);
if (!hasGoto) {
log.debug("Rule {} has no output.", rule);
}
return null;
}
ConnectPoint cp = new ConnectPoint(rule.deviceId(), port);
......
......@@ -310,7 +310,7 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv
break;
}
default:
log.debug("Unhandled message type: {}", msg.getType());
break;
}
}
......