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
Showing
6 changed files
with
63 additions
and
6 deletions
This diff is collapsed. Click to expand it.
... | @@ -18,30 +18,59 @@ package org.onosproject.bgprouter; | ... | @@ -18,30 +18,59 @@ package org.onosproject.bgprouter; |
18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
19 | import org.onlab.packet.IpAddress; | 19 | import org.onlab.packet.IpAddress; |
20 | import org.onlab.packet.MacAddress; | 20 | import org.onlab.packet.MacAddress; |
21 | +import org.onosproject.net.group.GroupKey; | ||
21 | 22 | ||
22 | import java.util.Objects; | 23 | import java.util.Objects; |
23 | 24 | ||
24 | /** | 25 | /** |
25 | - * Created by jono on 2/12/15. | 26 | + * Represents a next hop for routing, whose MAC address has already been resolved. |
26 | */ | 27 | */ |
27 | public class NextHop { | 28 | public class NextHop { |
28 | 29 | ||
29 | private final IpAddress ip; | 30 | private final IpAddress ip; |
30 | private final MacAddress mac; | 31 | private final MacAddress mac; |
32 | + private final GroupKey group; | ||
31 | 33 | ||
32 | - public NextHop(IpAddress ip, MacAddress mac) { | 34 | + /** |
35 | + * Creates a new next hop. | ||
36 | + * | ||
37 | + * @param ip next hop's IP address | ||
38 | + * @param mac next hop's MAC address | ||
39 | + * @param group next hop's group | ||
40 | + */ | ||
41 | + public NextHop(IpAddress ip, MacAddress mac, GroupKey group) { | ||
33 | this.ip = ip; | 42 | this.ip = ip; |
34 | this.mac = mac; | 43 | this.mac = mac; |
44 | + this.group = group; | ||
35 | } | 45 | } |
36 | 46 | ||
47 | + /** | ||
48 | + * Returns the next hop's IP address. | ||
49 | + * | ||
50 | + * @return next hop's IP address | ||
51 | + */ | ||
37 | public IpAddress ip() { | 52 | public IpAddress ip() { |
38 | return ip; | 53 | return ip; |
39 | } | 54 | } |
40 | 55 | ||
56 | + /** | ||
57 | + * Returns the next hop's MAC address. | ||
58 | + * | ||
59 | + * @return next hop's MAC address | ||
60 | + */ | ||
41 | public MacAddress mac() { | 61 | public MacAddress mac() { |
42 | return mac; | 62 | return mac; |
43 | } | 63 | } |
44 | 64 | ||
65 | + /** | ||
66 | + * Returns the next hop group. | ||
67 | + * | ||
68 | + * @return group | ||
69 | + */ | ||
70 | + public GroupKey group() { | ||
71 | + return group; | ||
72 | + } | ||
73 | + | ||
45 | @Override | 74 | @Override |
46 | public boolean equals(Object o) { | 75 | public boolean equals(Object o) { |
47 | if (!(o instanceof NextHop)) { | 76 | if (!(o instanceof NextHop)) { |
... | @@ -51,12 +80,13 @@ public class NextHop { | ... | @@ -51,12 +80,13 @@ public class NextHop { |
51 | NextHop that = (NextHop) o; | 80 | NextHop that = (NextHop) o; |
52 | 81 | ||
53 | return Objects.equals(this.ip, that.ip) && | 82 | return Objects.equals(this.ip, that.ip) && |
54 | - Objects.equals(this.mac, that.mac); | 83 | + Objects.equals(this.mac, that.mac) && |
84 | + Objects.equals(this.group, that.group); | ||
55 | } | 85 | } |
56 | 86 | ||
57 | @Override | 87 | @Override |
58 | public int hashCode() { | 88 | public int hashCode() { |
59 | - return Objects.hash(ip, mac); | 89 | + return Objects.hash(ip, mac, group); |
60 | } | 90 | } |
61 | 91 | ||
62 | @Override | 92 | @Override |
... | @@ -64,6 +94,7 @@ public class NextHop { | ... | @@ -64,6 +94,7 @@ public class NextHop { |
64 | return MoreObjects.toStringHelper(getClass()) | 94 | return MoreObjects.toStringHelper(getClass()) |
65 | .add("ip", ip) | 95 | .add("ip", ip) |
66 | .add("mac", mac) | 96 | .add("mac", mac) |
97 | + .add("group", group) | ||
67 | .toString(); | 98 | .toString(); |
68 | } | 99 | } |
69 | } | 100 | } | ... | ... |
... | @@ -24,16 +24,26 @@ import java.util.Objects; | ... | @@ -24,16 +24,26 @@ import java.util.Objects; |
24 | import static com.google.common.base.Preconditions.checkNotNull; | 24 | import static com.google.common.base.Preconditions.checkNotNull; |
25 | 25 | ||
26 | /** | 26 | /** |
27 | - * Created by jono on 2/16/15. | 27 | + * Identifier for a next hop group. |
28 | */ | 28 | */ |
29 | public class NextHopGroupKey implements GroupKey { | 29 | public class NextHopGroupKey implements GroupKey { |
30 | 30 | ||
31 | private final IpAddress address; | 31 | private final IpAddress address; |
32 | 32 | ||
33 | + /** | ||
34 | + * Creates a new next hop group key. | ||
35 | + * | ||
36 | + * @param address next hop's IP address | ||
37 | + */ | ||
33 | public NextHopGroupKey(IpAddress address) { | 38 | public NextHopGroupKey(IpAddress address) { |
34 | this.address = checkNotNull(address); | 39 | this.address = checkNotNull(address); |
35 | } | 40 | } |
36 | 41 | ||
42 | + /** | ||
43 | + * Returns the next hop's IP address. | ||
44 | + * | ||
45 | + * @return next hop's IP address | ||
46 | + */ | ||
37 | public IpAddress address() { | 47 | public IpAddress address() { |
38 | return address; | 48 | return address; |
39 | } | 49 | } | ... | ... |
... | @@ -288,8 +288,16 @@ public class DistributedStatisticStore implements StatisticStore { | ... | @@ -288,8 +288,16 @@ public class DistributedStatisticStore implements StatisticStore { |
288 | 288 | ||
289 | private ConnectPoint buildConnectPoint(FlowRule rule) { | 289 | private ConnectPoint buildConnectPoint(FlowRule rule) { |
290 | PortNumber port = getOutput(rule); | 290 | PortNumber port = getOutput(rule); |
291 | + | ||
292 | + boolean hasGoto = rule.treatment().instructions() | ||
293 | + .stream() | ||
294 | + .anyMatch(i -> (i instanceof Instructions.GroupInstruction) | ||
295 | + || (i instanceof Instructions.TableTypeTransition)); | ||
296 | + | ||
291 | if (port == null) { | 297 | if (port == null) { |
298 | + if (!hasGoto) { | ||
292 | log.debug("Rule {} has no output.", rule); | 299 | log.debug("Rule {} has no output.", rule); |
300 | + } | ||
293 | return null; | 301 | return null; |
294 | } | 302 | } |
295 | ConnectPoint cp = new ConnectPoint(rule.deviceId(), port); | 303 | ConnectPoint cp = new ConnectPoint(rule.deviceId(), port); | ... | ... |
... | @@ -154,8 +154,16 @@ public class SimpleStatisticStore implements StatisticStore { | ... | @@ -154,8 +154,16 @@ public class SimpleStatisticStore implements StatisticStore { |
154 | 154 | ||
155 | private ConnectPoint buildConnectPoint(FlowRule rule) { | 155 | private ConnectPoint buildConnectPoint(FlowRule rule) { |
156 | PortNumber port = getOutput(rule); | 156 | PortNumber port = getOutput(rule); |
157 | + | ||
158 | + boolean hasGoto = rule.treatment().instructions() | ||
159 | + .stream() | ||
160 | + .anyMatch(i -> (i instanceof Instructions.GroupInstruction) | ||
161 | + || (i instanceof Instructions.TableTypeTransition)); | ||
162 | + | ||
157 | if (port == null) { | 163 | if (port == null) { |
164 | + if (!hasGoto) { | ||
158 | log.debug("Rule {} has no output.", rule); | 165 | log.debug("Rule {} has no output.", rule); |
166 | + } | ||
159 | return null; | 167 | return null; |
160 | } | 168 | } |
161 | ConnectPoint cp = new ConnectPoint(rule.deviceId(), port); | 169 | ConnectPoint cp = new ConnectPoint(rule.deviceId(), port); | ... | ... |
... | @@ -310,7 +310,7 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv | ... | @@ -310,7 +310,7 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv |
310 | break; | 310 | break; |
311 | } | 311 | } |
312 | default: | 312 | default: |
313 | - log.debug("Unhandled message type: {}", msg.getType()); | 313 | + break; |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ... | ... |
-
Please register or login to post a comment