Cleanup a few of the CORD apps.
* Removed or turned per-packet logs down to trace in the PIM app * Can now reconfigure remote sync host in CordMcast * CordMcast catches REST exceptions rather than bombing Change-Id: Iae027d5ce1d9047827ea80b071dc77ca49c65206
Showing
8 changed files
with
64 additions
and
94 deletions
| ... | @@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; | ... | @@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; |
| 21 | import com.google.common.collect.Lists; | 21 | import com.google.common.collect.Lists; |
| 22 | import com.google.common.collect.Maps; | 22 | import com.google.common.collect.Maps; |
| 23 | import com.sun.jersey.api.client.Client; | 23 | import com.sun.jersey.api.client.Client; |
| 24 | +import com.sun.jersey.api.client.ClientHandlerException; | ||
| 24 | import com.sun.jersey.api.client.WebResource; | 25 | import com.sun.jersey.api.client.WebResource; |
| 25 | import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; | 26 | import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; |
| 26 | import org.apache.felix.scr.annotations.Activate; | 27 | import org.apache.felix.scr.annotations.Activate; |
| ... | @@ -83,6 +84,7 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -83,6 +84,7 @@ import static org.slf4j.LoggerFactory.getLogger; |
| 83 | @Component(immediate = true) | 84 | @Component(immediate = true) |
| 84 | public class CordMcast { | 85 | public class CordMcast { |
| 85 | 86 | ||
| 87 | + private static final int DEFAULT_REST_TIMEOUT_MS = 2000; | ||
| 86 | private static final int DEFAULT_PRIORITY = 1000; | 88 | private static final int DEFAULT_PRIORITY = 1000; |
| 87 | private static final short DEFAULT_MCAST_VLAN = 4000; | 89 | private static final short DEFAULT_MCAST_VLAN = 4000; |
| 88 | private static final String DEFAULT_SYNC_HOST = "10.90.0.8:8181"; | 90 | private static final String DEFAULT_SYNC_HOST = "10.90.0.8:8181"; |
| ... | @@ -149,8 +151,6 @@ public class CordMcast { | ... | @@ -149,8 +151,6 @@ public class CordMcast { |
| 149 | 151 | ||
| 150 | appId = coreService.registerApplication("org.onosproject.cordmcast"); | 152 | appId = coreService.registerApplication("org.onosproject.cordmcast"); |
| 151 | 153 | ||
| 152 | - fabricOnosUrl = "http://" + syncHost + "/onos/v1/mcast"; | ||
| 153 | - | ||
| 154 | clearRemoteRoutes(); | 154 | clearRemoteRoutes(); |
| 155 | 155 | ||
| 156 | mcastService.addListener(listener); | 156 | mcastService.addListener(listener); |
| ... | @@ -192,7 +192,7 @@ public class CordMcast { | ... | @@ -192,7 +192,7 @@ public class CordMcast { |
| 192 | s = get(properties, "priority"); | 192 | s = get(properties, "priority"); |
| 193 | priority = isNullOrEmpty(s) ? DEFAULT_PRIORITY : Integer.parseInt(s.trim()); | 193 | priority = isNullOrEmpty(s) ? DEFAULT_PRIORITY : Integer.parseInt(s.trim()); |
| 194 | 194 | ||
| 195 | - s = get(properties, syncHost); | 195 | + s = get(properties, "syncHost"); |
| 196 | syncHost = isNullOrEmpty(s) ? DEFAULT_SYNC_HOST : s.trim(); | 196 | syncHost = isNullOrEmpty(s) ? DEFAULT_SYNC_HOST : s.trim(); |
| 197 | } catch (Exception e) { | 197 | } catch (Exception e) { |
| 198 | user = DEFAULT_USER; | 198 | user = DEFAULT_USER; |
| ... | @@ -202,6 +202,11 @@ public class CordMcast { | ... | @@ -202,6 +202,11 @@ public class CordMcast { |
| 202 | vlanEnabled = false; | 202 | vlanEnabled = false; |
| 203 | priority = DEFAULT_PRIORITY; | 203 | priority = DEFAULT_PRIORITY; |
| 204 | } | 204 | } |
| 205 | + fabricOnosUrl = createRemoteUrl(syncHost); | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + private static String createRemoteUrl(String remoteHost) { | ||
| 209 | + return "http://" + remoteHost + "/onos/v1/mcast"; | ||
| 205 | } | 210 | } |
| 206 | 211 | ||
| 207 | private class InternalMulticastListener implements McastListener { | 212 | private class InternalMulticastListener implements McastListener { |
| ... | @@ -369,13 +374,18 @@ public class CordMcast { | ... | @@ -369,13 +374,18 @@ public class CordMcast { |
| 369 | return; | 374 | return; |
| 370 | } | 375 | } |
| 371 | 376 | ||
| 372 | - log.debug("Sending route to other ONOS: {}", route); | 377 | + log.debug("Sending route {} to other ONOS {}", route, fabricOnosUrl); |
| 373 | 378 | ||
| 374 | WebResource.Builder builder = getClientBuilder(fabricOnosUrl); | 379 | WebResource.Builder builder = getClientBuilder(fabricOnosUrl); |
| 375 | 380 | ||
| 376 | ObjectNode json = codecService.getCodec(McastRoute.class) | 381 | ObjectNode json = codecService.getCodec(McastRoute.class) |
| 377 | .encode(route, new AbstractWebResource()); | 382 | .encode(route, new AbstractWebResource()); |
| 378 | - builder.post(json.toString()); | 383 | + |
| 384 | + try { | ||
| 385 | + builder.post(json.toString()); | ||
| 386 | + } catch (ClientHandlerException e) { | ||
| 387 | + log.warn("Unable to send route to remote controller: {}", e.getMessage()); | ||
| 388 | + } | ||
| 379 | } | 389 | } |
| 380 | 390 | ||
| 381 | private void removeRemoteRoute(McastRoute route) { | 391 | private void removeRemoteRoute(McastRoute route) { |
| ... | @@ -384,13 +394,17 @@ public class CordMcast { | ... | @@ -384,13 +394,17 @@ public class CordMcast { |
| 384 | return; | 394 | return; |
| 385 | } | 395 | } |
| 386 | 396 | ||
| 387 | - log.debug("Removing route from other ONOS: {}", route); | 397 | + log.debug("Removing route {} from other ONOS {}", route, fabricOnosUrl); |
| 388 | 398 | ||
| 389 | WebResource.Builder builder = getClientBuilder(fabricOnosUrl); | 399 | WebResource.Builder builder = getClientBuilder(fabricOnosUrl); |
| 390 | 400 | ||
| 391 | ObjectNode json = codecService.getCodec(McastRoute.class) | 401 | ObjectNode json = codecService.getCodec(McastRoute.class) |
| 392 | .encode(route, new AbstractWebResource()); | 402 | .encode(route, new AbstractWebResource()); |
| 393 | - builder.delete(json.toString()); | 403 | + try { |
| 404 | + builder.delete(json.toString()); | ||
| 405 | + } catch (ClientHandlerException e) { | ||
| 406 | + log.warn("Unable to delete route from remote controller: {}", e.getMessage()); | ||
| 407 | + } | ||
| 394 | } | 408 | } |
| 395 | 409 | ||
| 396 | private void clearRemoteRoutes() { | 410 | private void clearRemoteRoutes() { |
| ... | @@ -399,23 +413,28 @@ public class CordMcast { | ... | @@ -399,23 +413,28 @@ public class CordMcast { |
| 399 | return; | 413 | return; |
| 400 | } | 414 | } |
| 401 | 415 | ||
| 402 | - log.debug("Clearing remote multicast routes"); | 416 | + log.debug("Clearing remote multicast routes from {}", fabricOnosUrl); |
| 403 | 417 | ||
| 404 | WebResource.Builder builder = getClientBuilder(fabricOnosUrl); | 418 | WebResource.Builder builder = getClientBuilder(fabricOnosUrl); |
| 405 | - | ||
| 406 | - String response = builder | ||
| 407 | - .accept(MediaType.APPLICATION_JSON_TYPE) | ||
| 408 | - .get(String.class); | ||
| 409 | - | ||
| 410 | - JsonCodec<McastRoute> routeCodec = codecService.getCodec(McastRoute.class); | ||
| 411 | - ObjectMapper mapper = new ObjectMapper(); | ||
| 412 | List<McastRoute> mcastRoutes = Lists.newArrayList(); | 419 | List<McastRoute> mcastRoutes = Lists.newArrayList(); |
| 420 | + | ||
| 413 | try { | 421 | try { |
| 422 | + String response = builder | ||
| 423 | + .accept(MediaType.APPLICATION_JSON_TYPE) | ||
| 424 | + .get(String.class); | ||
| 425 | + | ||
| 426 | + JsonCodec<McastRoute> routeCodec = codecService.getCodec(McastRoute.class); | ||
| 427 | + ObjectMapper mapper = new ObjectMapper(); | ||
| 428 | + | ||
| 429 | + | ||
| 414 | ObjectNode node = (ObjectNode) mapper.readTree(response); | 430 | ObjectNode node = (ObjectNode) mapper.readTree(response); |
| 415 | ArrayNode list = (ArrayNode) node.path("routes"); | 431 | ArrayNode list = (ArrayNode) node.path("routes"); |
| 416 | 432 | ||
| 417 | list.forEach(n -> mcastRoutes.add( | 433 | list.forEach(n -> mcastRoutes.add( |
| 418 | routeCodec.decode((ObjectNode) n, new AbstractWebResource()))); | 434 | routeCodec.decode((ObjectNode) n, new AbstractWebResource()))); |
| 435 | + | ||
| 436 | + } catch (ClientHandlerException e) { | ||
| 437 | + log.warn("Unable to clear routes from remote controller: {}", e.getMessage()); | ||
| 419 | } catch (IOException e) { | 438 | } catch (IOException e) { |
| 420 | log.warn("Error clearing remote routes", e); | 439 | log.warn("Error clearing remote routes", e); |
| 421 | } | 440 | } |
| ... | @@ -429,6 +448,8 @@ public class CordMcast { | ... | @@ -429,6 +448,8 @@ public class CordMcast { |
| 429 | 448 | ||
| 430 | private WebResource.Builder getClientBuilder(String uri) { | 449 | private WebResource.Builder getClientBuilder(String uri) { |
| 431 | Client client = Client.create(); | 450 | Client client = Client.create(); |
| 451 | + client.setConnectTimeout(DEFAULT_REST_TIMEOUT_MS); | ||
| 452 | + client.setReadTimeout(DEFAULT_REST_TIMEOUT_MS); | ||
| 432 | client.addFilter(new HTTPBasicAuthFilter(user, password)); | 453 | client.addFilter(new HTTPBasicAuthFilter(user, password)); |
| 433 | WebResource resource = client.resource(uri); | 454 | WebResource resource = client.resource(uri); |
| 434 | return resource.accept(JSON_UTF_8.toString()) | 455 | return resource.accept(JSON_UTF_8.toString()) | ... | ... |
| ... | @@ -403,10 +403,8 @@ public class IgmpSnoop { | ... | @@ -403,10 +403,8 @@ public class IgmpSnoop { |
| 403 | return; | 403 | return; |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | - /* | 406 | + |
| 407 | - * IPv6 MLD packets are handled by ICMP6. We'll only deal | 407 | + // IPv6 MLD packets are handled by ICMP6. We'll only deal with IPv4. |
| 408 | - * with IPv4. | ||
| 409 | - */ | ||
| 410 | if (ethPkt.getEtherType() != Ethernet.TYPE_IPV4) { | 408 | if (ethPkt.getEtherType() != Ethernet.TYPE_IPV4) { |
| 411 | return; | 409 | return; |
| 412 | } | 410 | } |
| ... | @@ -414,29 +412,22 @@ public class IgmpSnoop { | ... | @@ -414,29 +412,22 @@ public class IgmpSnoop { |
| 414 | IPv4 ip = (IPv4) ethPkt.getPayload(); | 412 | IPv4 ip = (IPv4) ethPkt.getPayload(); |
| 415 | IpAddress gaddr = IpAddress.valueOf(ip.getDestinationAddress()); | 413 | IpAddress gaddr = IpAddress.valueOf(ip.getDestinationAddress()); |
| 416 | IpAddress saddr = Ip4Address.valueOf(ip.getSourceAddress()); | 414 | IpAddress saddr = Ip4Address.valueOf(ip.getSourceAddress()); |
| 417 | - log.debug("Packet ({}, {}) -> ingress port: {}", saddr, gaddr, | 415 | + log.trace("Packet ({}, {}) -> ingress port: {}", saddr, gaddr, |
| 418 | context.inPacket().receivedFrom()); | 416 | context.inPacket().receivedFrom()); |
| 419 | 417 | ||
| 420 | 418 | ||
| 421 | - if (ip.getProtocol() != IPv4.PROTOCOL_IGMP) { | 419 | + if (ip.getProtocol() != IPv4.PROTOCOL_IGMP || |
| 422 | - log.debug("IGMP Picked up a non IGMP packet."); | 420 | + !IpPrefix.MULTICAST_RANGE.contains(gaddr)) { |
| 423 | - return; | ||
| 424 | - } | ||
| 425 | - | ||
| 426 | - IpPrefix mcast = IpPrefix.valueOf(DEFAULT_MCAST_ADDR); | ||
| 427 | - if (!mcast.contains(gaddr)) { | ||
| 428 | - log.debug("IGMP Picked up a non multicast packet."); | ||
| 429 | return; | 421 | return; |
| 430 | } | 422 | } |
| 431 | 423 | ||
| 432 | - if (mcast.contains(saddr)) { | 424 | + if (IpPrefix.MULTICAST_RANGE.contains(saddr)) { |
| 433 | log.debug("IGMP Picked up a packet with a multicast source address."); | 425 | log.debug("IGMP Picked up a packet with a multicast source address."); |
| 434 | return; | 426 | return; |
| 435 | } | 427 | } |
| 436 | 428 | ||
| 437 | IGMP igmp = (IGMP) ip.getPayload(); | 429 | IGMP igmp = (IGMP) ip.getPayload(); |
| 438 | switch (igmp.getIgmpType()) { | 430 | switch (igmp.getIgmpType()) { |
| 439 | - | ||
| 440 | case IGMP.TYPE_IGMPV3_MEMBERSHIP_REPORT: | 431 | case IGMP.TYPE_IGMPV3_MEMBERSHIP_REPORT: |
| 441 | processMembership(igmp, pkt.receivedFrom()); | 432 | processMembership(igmp, pkt.receivedFrom()); |
| 442 | break; | 433 | break; |
| ... | @@ -453,7 +444,7 @@ public class IgmpSnoop { | ... | @@ -453,7 +444,7 @@ public class IgmpSnoop { |
| 453 | igmp.getIgmpType()); | 444 | igmp.getIgmpType()); |
| 454 | break; | 445 | break; |
| 455 | default: | 446 | default: |
| 456 | - log.debug("Unknown IGMP message type: {}", igmp.getIgmpType()); | 447 | + log.warn("Unknown IGMP message type: {}", igmp.getIgmpType()); |
| 457 | break; | 448 | break; |
| 458 | } | 449 | } |
| 459 | } | 450 | } |
| ... | @@ -551,6 +542,5 @@ public class IgmpSnoop { | ... | @@ -551,6 +542,5 @@ public class IgmpSnoop { |
| 551 | .filter(p -> !oltData.get(p.element().id()).uplink().equals(p.number())) | 542 | .filter(p -> !oltData.get(p.element().id()).uplink().equals(p.number())) |
| 552 | .filter(p -> p.isEnabled()) | 543 | .filter(p -> p.isEnabled()) |
| 553 | .forEach(p -> processFilterObjective((DeviceId) p.element().id(), p, false)); | 544 | .forEach(p -> processFilterObjective((DeviceId) p.element().id(), p, false)); |
| 554 | - | ||
| 555 | } | 545 | } |
| 556 | } | 546 | } | ... | ... |
| ... | @@ -109,7 +109,6 @@ public class PIMApplication { | ... | @@ -109,7 +109,6 @@ public class PIMApplication { |
| 109 | * they arrived on, then forward them on to be processed by the appropriate entity. | 109 | * they arrived on, then forward them on to be processed by the appropriate entity. |
| 110 | */ | 110 | */ |
| 111 | public class PIMPacketProcessor implements PacketProcessor { | 111 | public class PIMPacketProcessor implements PacketProcessor { |
| 112 | - private final Logger log = getLogger(getClass()); | ||
| 113 | 112 | ||
| 114 | @Override | 113 | @Override |
| 115 | public void process(PacketContext context) { | 114 | public void process(PacketContext context) { |
| ... | @@ -131,14 +130,13 @@ public class PIMApplication { | ... | @@ -131,14 +130,13 @@ public class PIMApplication { |
| 131 | Ethernet eth = pkt.parsed(); | 130 | Ethernet eth = pkt.parsed(); |
| 132 | if (eth == null) { | 131 | if (eth == null) { |
| 133 | // problem getting the ethernet pkt. Log it debug to avoid spamming log file | 132 | // problem getting the ethernet pkt. Log it debug to avoid spamming log file |
| 134 | - log.debug("Could not retrieve ethnernet packet from the parsed packet"); | 133 | + log.debug("Could not retrieve ethernet packet from the parsed packet"); |
| 135 | return; | 134 | return; |
| 136 | } | 135 | } |
| 137 | 136 | ||
| 138 | // Get the PIM Interface the packet was received on. | 137 | // Get the PIM Interface the packet was received on. |
| 139 | PIMInterface pimi = pimInterfaceManager.getPIMInterface(pkt.receivedFrom()); | 138 | PIMInterface pimi = pimInterfaceManager.getPIMInterface(pkt.receivedFrom()); |
| 140 | if (pimi == null) { | 139 | if (pimi == null) { |
| 141 | - log.debug("We received PIM packet from a non PIM interface: " + pkt.receivedFrom().toString()); | ||
| 142 | return; | 140 | return; |
| 143 | } | 141 | } |
| 144 | 142 | ||
| ... | @@ -148,8 +146,7 @@ public class PIMApplication { | ... | @@ -148,8 +146,7 @@ public class PIMApplication { |
| 148 | * TODO: Is it possible that PIM interface processing should move to the | 146 | * TODO: Is it possible that PIM interface processing should move to the |
| 149 | * PIMInterfaceManager directly? | 147 | * PIMInterfaceManager directly? |
| 150 | */ | 148 | */ |
| 151 | - PIMPacketHandler ph = new PIMPacketHandler(); | 149 | + pimPacketHandler.processPacket(eth, pimi); |
| 152 | - ph.processPacket(eth, pimi); | ||
| 153 | } | 150 | } |
| 154 | } | 151 | } |
| 155 | 152 | ... | ... |
| ... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.pim.impl; | 16 | package org.onosproject.pim.impl; |
| 17 | 17 | ||
| 18 | +import com.google.common.collect.ImmutableList; | ||
| 18 | import org.onlab.packet.Ethernet; | 19 | import org.onlab.packet.Ethernet; |
| 19 | import org.onlab.packet.IPv4; | 20 | import org.onlab.packet.IPv4; |
| 20 | import org.onlab.packet.Ip4Address; | 21 | import org.onlab.packet.Ip4Address; |
| ... | @@ -38,7 +39,6 @@ import org.slf4j.Logger; | ... | @@ -38,7 +39,6 @@ import org.slf4j.Logger; |
| 38 | 39 | ||
| 39 | import java.nio.ByteBuffer; | 40 | import java.nio.ByteBuffer; |
| 40 | import java.util.Collection; | 41 | import java.util.Collection; |
| 41 | -import java.util.HashMap; | ||
| 42 | import java.util.List; | 42 | import java.util.List; |
| 43 | import java.util.Map; | 43 | import java.util.Map; |
| 44 | import java.util.Random; | 44 | import java.util.Random; |
| ... | @@ -87,7 +87,7 @@ public final class PIMInterface { | ... | @@ -87,7 +87,7 @@ public final class PIMInterface { |
| 87 | private IpAddress drIpaddress; | 87 | private IpAddress drIpaddress; |
| 88 | 88 | ||
| 89 | // A map of all our PIM neighbors keyed on our neighbors IP address | 89 | // A map of all our PIM neighbors keyed on our neighbors IP address |
| 90 | - private Map<IpAddress, PIMNeighbor> pimNeighbors = new HashMap<>(); | 90 | + private Map<IpAddress, PIMNeighbor> pimNeighbors = new ConcurrentHashMap<>(); |
| 91 | 91 | ||
| 92 | private Map<McastRoute, RouteData> routes = new ConcurrentHashMap<>(); | 92 | private Map<McastRoute, RouteData> routes = new ConcurrentHashMap<>(); |
| 93 | 93 | ||
| ... | @@ -224,7 +224,7 @@ public final class PIMInterface { | ... | @@ -224,7 +224,7 @@ public final class PIMInterface { |
| 224 | * @return PIM neighbors | 224 | * @return PIM neighbors |
| 225 | */ | 225 | */ |
| 226 | public Collection<PIMNeighbor> getNeighbors() { | 226 | public Collection<PIMNeighbor> getNeighbors() { |
| 227 | - return pimNeighbors.values(); | 227 | + return ImmutableList.copyOf(pimNeighbors.values()); |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | public Collection<McastRoute> getRoutes() { | 230 | public Collection<McastRoute> getRoutes() { |
| ... | @@ -297,6 +297,9 @@ public final class PIMInterface { | ... | @@ -297,6 +297,9 @@ public final class PIMInterface { |
| 297 | * @param ethPkt the Ethernet packet header | 297 | * @param ethPkt the Ethernet packet header |
| 298 | */ | 298 | */ |
| 299 | public void processHello(Ethernet ethPkt) { | 299 | public void processHello(Ethernet ethPkt) { |
| 300 | + if (log.isTraceEnabled()) { | ||
| 301 | + log.trace("Received a PIM hello packet"); | ||
| 302 | + } | ||
| 300 | 303 | ||
| 301 | // We'll need to save our neighbors MAC address | 304 | // We'll need to save our neighbors MAC address |
| 302 | MacAddress nbrmac = ethPkt.getSourceMAC(); | 305 | MacAddress nbrmac = ethPkt.getSourceMAC(); |
| ... | @@ -476,39 +479,6 @@ public final class PIMInterface { | ... | @@ -476,39 +479,6 @@ public final class PIMInterface { |
| 476 | data.timestamp = System.currentTimeMillis(); | 479 | data.timestamp = System.currentTimeMillis(); |
| 477 | } | 480 | } |
| 478 | 481 | ||
| 479 | - /*private void sendPrune(McastRoute route, RouteData data) { | ||
| 480 | - PIMJoinPrune jp = new PIMJoinPrune(); | ||
| 481 | - | ||
| 482 | - jp.addJoinPrune(route.source().toIpPrefix(), route.group().toIpPrefix(), false); | ||
| 483 | - jp.setHoldTime((short) 0); | ||
| 484 | - jp.setUpstreamAddr(new PIMAddrUnicast(data.ipAddress.toString())); | ||
| 485 | - | ||
| 486 | - PIM pim = new PIM(); | ||
| 487 | - pim.setPIMType(PIM.TYPE_JOIN_PRUNE_REQUEST); | ||
| 488 | - pim.setPayload(jp); | ||
| 489 | - | ||
| 490 | - IPv4 ipv4 = new IPv4(); | ||
| 491 | - ipv4.setDestinationAddress(PIM.PIM_ADDRESS.getIp4Address().toInt()); | ||
| 492 | - ipv4.setSourceAddress(getIpAddress().getIp4Address().toInt()); | ||
| 493 | - ipv4.setProtocol(IPv4.PROTOCOL_PIM); | ||
| 494 | - ipv4.setTtl((byte) 1); | ||
| 495 | - ipv4.setDiffServ((byte) 0xc0); | ||
| 496 | - ipv4.setPayload(pim); | ||
| 497 | - | ||
| 498 | - Ethernet eth = new Ethernet(); | ||
| 499 | - eth.setSourceMACAddress(onosInterface.mac()); | ||
| 500 | - eth.setDestinationMACAddress(MacAddress.valueOf("01:00:5E:00:00:0d")); | ||
| 501 | - eth.setEtherType(Ethernet.TYPE_IPV4); | ||
| 502 | - eth.setPayload(ipv4); | ||
| 503 | - | ||
| 504 | - TrafficTreatment treatment = DefaultTrafficTreatment.builder() | ||
| 505 | - .setOutput(onosInterface.connectPoint().port()) | ||
| 506 | - .build(); | ||
| 507 | - | ||
| 508 | - packetService.emit(new DefaultOutboundPacket(onosInterface.connectPoint().deviceId(), | ||
| 509 | - treatment, ByteBuffer.wrap(eth.serialize()))); | ||
| 510 | - }*/ | ||
| 511 | - | ||
| 512 | /** | 482 | /** |
| 513 | * Returns a builder for a PIM interface. | 483 | * Returns a builder for a PIM interface. |
| 514 | * | 484 | * | ... | ... |
| ... | @@ -177,17 +177,11 @@ public class PIMInterfaceManager implements PIMInterfaceService { | ... | @@ -177,17 +177,11 @@ public class PIMInterfaceManager implements PIMInterfaceService { |
| 177 | log.info("Stopped"); | 177 | log.info("Stopped"); |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | - /** | ||
| 181 | - * Return the PIMInterface that corresponds to the given ConnectPoint. | ||
| 182 | - * | ||
| 183 | - * @param cp The ConnectPoint we want to get the PIMInterface for | ||
| 184 | - * @return The PIMInterface if it exists, NULL if it does not exist. | ||
| 185 | - */ | ||
| 186 | @Override | 180 | @Override |
| 187 | public PIMInterface getPIMInterface(ConnectPoint cp) { | 181 | public PIMInterface getPIMInterface(ConnectPoint cp) { |
| 188 | - PIMInterface pi = pimInterfaces.getOrDefault(cp, null); | 182 | + PIMInterface pi = pimInterfaces.get(cp); |
| 189 | - if (pi == null) { | 183 | + if (pi == null && log.isTraceEnabled()) { |
| 190 | - log.warn("We have been asked for an Interface we don't have: " + cp.toString()); | 184 | + log.trace("We have been asked for an Interface we don't have: {}", cp); |
| 191 | } | 185 | } |
| 192 | return pi; | 186 | return pi; |
| 193 | } | 187 | } | ... | ... |
| ... | @@ -29,12 +29,12 @@ import java.util.Set; | ... | @@ -29,12 +29,12 @@ import java.util.Set; |
| 29 | public interface PIMInterfaceService { | 29 | public interface PIMInterfaceService { |
| 30 | 30 | ||
| 31 | /** | 31 | /** |
| 32 | - * Return the PIMInterface associated with the given ConnectPoint. | 32 | + * Returns the PIM interface associated with the given connect point. |
| 33 | * | 33 | * |
| 34 | - * @param cp The ConnectPoint we want to get the PIMInterface for. | 34 | + * @param cp the connect point we want to get the PIM interface for |
| 35 | - * @return the PIMInterface if it exists, NULL if it does not exist. | 35 | + * @return the PIM interface if it exists, otherwise null |
| 36 | */ | 36 | */ |
| 37 | - public PIMInterface getPIMInterface(ConnectPoint cp); | 37 | + PIMInterface getPIMInterface(ConnectPoint cp); |
| 38 | 38 | ||
| 39 | /** | 39 | /** |
| 40 | * Retrieves the set of all interfaces running PIM. | 40 | * Retrieves the set of all interfaces running PIM. | ... | ... |
| ... | @@ -50,20 +50,20 @@ public class PIMPacketHandler { | ... | @@ -50,20 +50,20 @@ public class PIMPacketHandler { |
| 50 | 50 | ||
| 51 | // Sanitize the ethernet header to ensure it is IPv4. IPv6 we'll deal with later | 51 | // Sanitize the ethernet header to ensure it is IPv4. IPv6 we'll deal with later |
| 52 | if (ethPkt.getEtherType() != Ethernet.TYPE_IPV4) { | 52 | if (ethPkt.getEtherType() != Ethernet.TYPE_IPV4) { |
| 53 | - log.debug("Recieved a non IPv4 packet"); | ||
| 54 | return; | 53 | return; |
| 55 | } | 54 | } |
| 56 | 55 | ||
| 57 | // Get the IP header | 56 | // Get the IP header |
| 58 | IPv4 ip = (IPv4) ethPkt.getPayload(); | 57 | IPv4 ip = (IPv4) ethPkt.getPayload(); |
| 59 | if (ip.getProtocol() != IPv4.PROTOCOL_PIM) { | 58 | if (ip.getProtocol() != IPv4.PROTOCOL_PIM) { |
| 60 | - log.debug("Received a non PIM IP packet"); | ||
| 61 | return; | 59 | return; |
| 62 | } | 60 | } |
| 63 | 61 | ||
| 64 | // Get the address of our the neighbor that sent this packet to us. | 62 | // Get the address of our the neighbor that sent this packet to us. |
| 65 | IpAddress nbraddr = IpAddress.valueOf(ip.getDestinationAddress()); | 63 | IpAddress nbraddr = IpAddress.valueOf(ip.getDestinationAddress()); |
| 66 | - log.debug("Packet " + nbraddr.toString() + " received on port " + pimi.toString()); | 64 | + if (log.isTraceEnabled()) { |
| 65 | + log.trace("Packet {} received on port {}", nbraddr, pimi); | ||
| 66 | + } | ||
| 67 | 67 | ||
| 68 | // Get the PIM header | 68 | // Get the PIM header |
| 69 | PIM pim = (PIM) ip.getPayload(); | 69 | PIM pim = (PIM) ip.getPayload(); |
| ... | @@ -71,19 +71,15 @@ public class PIMPacketHandler { | ... | @@ -71,19 +71,15 @@ public class PIMPacketHandler { |
| 71 | 71 | ||
| 72 | // Process the pim packet | 72 | // Process the pim packet |
| 73 | switch (pim.getPimMsgType()) { | 73 | switch (pim.getPimMsgType()) { |
| 74 | - | ||
| 75 | case PIM.TYPE_HELLO: | 74 | case PIM.TYPE_HELLO: |
| 76 | pimi.processHello(ethPkt); | 75 | pimi.processHello(ethPkt); |
| 77 | - log.debug("Received a PIM hello packet"); | ||
| 78 | break; | 76 | break; |
| 79 | - | ||
| 80 | case PIM.TYPE_JOIN_PRUNE_REQUEST: | 77 | case PIM.TYPE_JOIN_PRUNE_REQUEST: |
| 81 | pimi.processJoinPrune(ethPkt); | 78 | pimi.processJoinPrune(ethPkt); |
| 82 | log.debug("Received a PIM Join/Prune message"); | 79 | log.debug("Received a PIM Join/Prune message"); |
| 83 | break; | 80 | break; |
| 84 | - | ||
| 85 | default: | 81 | default: |
| 86 | - log.debug("Recieved unsupported PIM type: " + pim.getPimMsgType()); | 82 | + log.debug("Received unsupported PIM type: {}", pim.getPimMsgType()); |
| 87 | break; | 83 | break; |
| 88 | } | 84 | } |
| 89 | } | 85 | } | ... | ... |
| ... | @@ -31,6 +31,8 @@ public class IpPrefix { | ... | @@ -31,6 +31,8 @@ public class IpPrefix { |
| 31 | public static final int MAX_INET_MASK_LENGTH = IpAddress.INET_BIT_LENGTH; | 31 | public static final int MAX_INET_MASK_LENGTH = IpAddress.INET_BIT_LENGTH; |
| 32 | public static final int MAX_INET6_MASK_LENGTH = IpAddress.INET6_BIT_LENGTH; | 32 | public static final int MAX_INET6_MASK_LENGTH = IpAddress.INET6_BIT_LENGTH; |
| 33 | 33 | ||
| 34 | + public static final IpPrefix MULTICAST_RANGE = IpPrefix.valueOf("224.0.0.0/4"); | ||
| 35 | + | ||
| 34 | private final IpAddress address; | 36 | private final IpAddress address; |
| 35 | private final short prefixLength; | 37 | private final short prefixLength; |
| 36 | 38 | ... | ... |
-
Please register or login to post a comment