Committed by
Gerrit Code Review
ReactiveForwarding shouldn't always match ethertype or ipproto
Change-Id: Ie8fad0186f5a41596877463c0293748e6cf2d74f
Showing
1 changed file
with
27 additions
and
23 deletions
| ... | @@ -15,12 +15,6 @@ | ... | @@ -15,12 +15,6 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.fwd; | 16 | package org.onosproject.fwd; |
| 17 | 17 | ||
| 18 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 19 | - | ||
| 20 | -import java.util.Dictionary; | ||
| 21 | -import java.util.Set; | ||
| 22 | -import static com.google.common.base.Strings.isNullOrEmpty; | ||
| 23 | - | ||
| 24 | import org.apache.felix.scr.annotations.Activate; | 18 | import org.apache.felix.scr.annotations.Activate; |
| 25 | import org.apache.felix.scr.annotations.Component; | 19 | import org.apache.felix.scr.annotations.Component; |
| 26 | import org.apache.felix.scr.annotations.Deactivate; | 20 | import org.apache.felix.scr.annotations.Deactivate; |
| ... | @@ -29,14 +23,14 @@ import org.apache.felix.scr.annotations.Property; | ... | @@ -29,14 +23,14 @@ import org.apache.felix.scr.annotations.Property; |
| 29 | import org.apache.felix.scr.annotations.Reference; | 23 | import org.apache.felix.scr.annotations.Reference; |
| 30 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 24 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 31 | import org.onlab.packet.Ethernet; | 25 | import org.onlab.packet.Ethernet; |
| 32 | -import org.onlab.packet.IPv4; | ||
| 33 | -import org.onlab.packet.IPv6; | ||
| 34 | -import org.onlab.packet.TCP; | ||
| 35 | -import org.onlab.packet.UDP; | ||
| 36 | import org.onlab.packet.ICMP; | 26 | import org.onlab.packet.ICMP; |
| 37 | import org.onlab.packet.ICMP6; | 27 | import org.onlab.packet.ICMP6; |
| 28 | +import org.onlab.packet.IPv4; | ||
| 29 | +import org.onlab.packet.IPv6; | ||
| 38 | import org.onlab.packet.Ip4Prefix; | 30 | import org.onlab.packet.Ip4Prefix; |
| 39 | import org.onlab.packet.Ip6Prefix; | 31 | import org.onlab.packet.Ip6Prefix; |
| 32 | +import org.onlab.packet.TCP; | ||
| 33 | +import org.onlab.packet.UDP; | ||
| 40 | import org.onlab.packet.VlanId; | 34 | import org.onlab.packet.VlanId; |
| 41 | import org.onosproject.cfg.ComponentConfigService; | 35 | import org.onosproject.cfg.ComponentConfigService; |
| 42 | import org.onosproject.core.ApplicationId; | 36 | import org.onosproject.core.ApplicationId; |
| ... | @@ -62,6 +56,12 @@ import org.onosproject.net.topology.TopologyService; | ... | @@ -62,6 +56,12 @@ import org.onosproject.net.topology.TopologyService; |
| 62 | import org.osgi.service.component.ComponentContext; | 56 | import org.osgi.service.component.ComponentContext; |
| 63 | import org.slf4j.Logger; | 57 | import org.slf4j.Logger; |
| 64 | 58 | ||
| 59 | +import java.util.Dictionary; | ||
| 60 | +import java.util.Set; | ||
| 61 | + | ||
| 62 | +import static com.google.common.base.Strings.isNullOrEmpty; | ||
| 63 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 64 | + | ||
| 65 | /** | 65 | /** |
| 66 | * Sample reactive forwarding application. | 66 | * Sample reactive forwarding application. |
| 67 | */ | 67 | */ |
| ... | @@ -485,8 +485,7 @@ public class ReactiveForwarding { | ... | @@ -485,8 +485,7 @@ public class ReactiveForwarding { |
| 485 | } else { | 485 | } else { |
| 486 | builder.matchInPort(context.inPacket().receivedFrom().port()) | 486 | builder.matchInPort(context.inPacket().receivedFrom().port()) |
| 487 | .matchEthSrc(inPkt.getSourceMAC()) | 487 | .matchEthSrc(inPkt.getSourceMAC()) |
| 488 | - .matchEthDst(inPkt.getDestinationMAC()) | 488 | + .matchEthDst(inPkt.getDestinationMAC()); |
| 489 | - .matchEthType(inPkt.getEtherType()); | ||
| 490 | 489 | ||
| 491 | // If configured Match Vlan ID | 490 | // If configured Match Vlan ID |
| 492 | if (matchVlanId && inPkt.getVlanID() != Ethernet.VLAN_UNTAGGED) { | 491 | if (matchVlanId && inPkt.getVlanID() != Ethernet.VLAN_UNTAGGED) { |
| ... | @@ -506,9 +505,9 @@ public class ReactiveForwarding { | ... | @@ -506,9 +505,9 @@ public class ReactiveForwarding { |
| 506 | Ip4Prefix matchIp4DstPrefix = | 505 | Ip4Prefix matchIp4DstPrefix = |
| 507 | Ip4Prefix.valueOf(ipv4Packet.getDestinationAddress(), | 506 | Ip4Prefix.valueOf(ipv4Packet.getDestinationAddress(), |
| 508 | Ip4Prefix.MAX_MASK_LENGTH); | 507 | Ip4Prefix.MAX_MASK_LENGTH); |
| 509 | - builder.matchIPSrc(matchIp4SrcPrefix) | 508 | + builder.matchEthType(inPkt.getEtherType()) |
| 510 | - .matchIPDst(matchIp4DstPrefix) | 509 | + .matchIPSrc(matchIp4SrcPrefix) |
| 511 | - .matchIPProtocol(ipv4Protocol); | 510 | + .matchIPDst(matchIp4DstPrefix); |
| 512 | 511 | ||
| 513 | if (matchIpv4Dscp) { | 512 | if (matchIpv4Dscp) { |
| 514 | byte dscp = ipv4Packet.getDscp(); | 513 | byte dscp = ipv4Packet.getDscp(); |
| ... | @@ -518,17 +517,20 @@ public class ReactiveForwarding { | ... | @@ -518,17 +517,20 @@ public class ReactiveForwarding { |
| 518 | 517 | ||
| 519 | if (matchTcpUdpPorts && ipv4Protocol == IPv4.PROTOCOL_TCP) { | 518 | if (matchTcpUdpPorts && ipv4Protocol == IPv4.PROTOCOL_TCP) { |
| 520 | TCP tcpPacket = (TCP) ipv4Packet.getPayload(); | 519 | TCP tcpPacket = (TCP) ipv4Packet.getPayload(); |
| 521 | - builder.matchTcpSrc(tcpPacket.getSourcePort()) | 520 | + builder.matchIPProtocol(ipv4Protocol) |
| 521 | + .matchTcpSrc(tcpPacket.getSourcePort()) | ||
| 522 | .matchTcpDst(tcpPacket.getDestinationPort()); | 522 | .matchTcpDst(tcpPacket.getDestinationPort()); |
| 523 | } | 523 | } |
| 524 | if (matchTcpUdpPorts && ipv4Protocol == IPv4.PROTOCOL_UDP) { | 524 | if (matchTcpUdpPorts && ipv4Protocol == IPv4.PROTOCOL_UDP) { |
| 525 | UDP udpPacket = (UDP) ipv4Packet.getPayload(); | 525 | UDP udpPacket = (UDP) ipv4Packet.getPayload(); |
| 526 | - builder.matchUdpSrc(udpPacket.getSourcePort()) | 526 | + builder.matchIPProtocol(ipv4Protocol) |
| 527 | + .matchUdpSrc(udpPacket.getSourcePort()) | ||
| 527 | .matchUdpDst(udpPacket.getDestinationPort()); | 528 | .matchUdpDst(udpPacket.getDestinationPort()); |
| 528 | } | 529 | } |
| 529 | if (matchIcmpFields && ipv4Protocol == IPv4.PROTOCOL_ICMP) { | 530 | if (matchIcmpFields && ipv4Protocol == IPv4.PROTOCOL_ICMP) { |
| 530 | ICMP icmpPacket = (ICMP) ipv4Packet.getPayload(); | 531 | ICMP icmpPacket = (ICMP) ipv4Packet.getPayload(); |
| 531 | - builder.matchIcmpType(icmpPacket.getIcmpType()) | 532 | + builder.matchIPProtocol(ipv4Protocol) |
| 533 | + .matchIcmpType(icmpPacket.getIcmpType()) | ||
| 532 | .matchIcmpCode(icmpPacket.getIcmpCode()); | 534 | .matchIcmpCode(icmpPacket.getIcmpCode()); |
| 533 | } | 535 | } |
| 534 | } | 536 | } |
| ... | @@ -547,8 +549,7 @@ public class ReactiveForwarding { | ... | @@ -547,8 +549,7 @@ public class ReactiveForwarding { |
| 547 | Ip6Prefix.valueOf(ipv6Packet.getDestinationAddress(), | 549 | Ip6Prefix.valueOf(ipv6Packet.getDestinationAddress(), |
| 548 | Ip6Prefix.MAX_MASK_LENGTH); | 550 | Ip6Prefix.MAX_MASK_LENGTH); |
| 549 | builder.matchIPv6Src(matchIp6SrcPrefix) | 551 | builder.matchIPv6Src(matchIp6SrcPrefix) |
| 550 | - .matchIPv6Dst(matchIp6DstPrefix) | 552 | + .matchIPv6Dst(matchIp6DstPrefix); |
| 551 | - .matchIPProtocol(ipv6NextHeader); | ||
| 552 | 553 | ||
| 553 | if (matchIpv6FlowLabel) { | 554 | if (matchIpv6FlowLabel) { |
| 554 | builder.matchIPv6FlowLabel(ipv6Packet.getFlowLabel()); | 555 | builder.matchIPv6FlowLabel(ipv6Packet.getFlowLabel()); |
| ... | @@ -556,17 +557,20 @@ public class ReactiveForwarding { | ... | @@ -556,17 +557,20 @@ public class ReactiveForwarding { |
| 556 | 557 | ||
| 557 | if (matchTcpUdpPorts && ipv6NextHeader == IPv6.PROTOCOL_TCP) { | 558 | if (matchTcpUdpPorts && ipv6NextHeader == IPv6.PROTOCOL_TCP) { |
| 558 | TCP tcpPacket = (TCP) ipv6Packet.getPayload(); | 559 | TCP tcpPacket = (TCP) ipv6Packet.getPayload(); |
| 559 | - builder.matchTcpSrc(tcpPacket.getSourcePort()) | 560 | + builder.matchIPProtocol(ipv6NextHeader) |
| 561 | + .matchTcpSrc(tcpPacket.getSourcePort()) | ||
| 560 | .matchTcpDst(tcpPacket.getDestinationPort()); | 562 | .matchTcpDst(tcpPacket.getDestinationPort()); |
| 561 | } | 563 | } |
| 562 | if (matchTcpUdpPorts && ipv6NextHeader == IPv6.PROTOCOL_UDP) { | 564 | if (matchTcpUdpPorts && ipv6NextHeader == IPv6.PROTOCOL_UDP) { |
| 563 | UDP udpPacket = (UDP) ipv6Packet.getPayload(); | 565 | UDP udpPacket = (UDP) ipv6Packet.getPayload(); |
| 564 | - builder.matchUdpSrc(udpPacket.getSourcePort()) | 566 | + builder.matchIPProtocol(ipv6NextHeader) |
| 567 | + .matchUdpSrc(udpPacket.getSourcePort()) | ||
| 565 | .matchUdpDst(udpPacket.getDestinationPort()); | 568 | .matchUdpDst(udpPacket.getDestinationPort()); |
| 566 | } | 569 | } |
| 567 | if (matchIcmpFields && ipv6NextHeader == IPv6.PROTOCOL_ICMP6) { | 570 | if (matchIcmpFields && ipv6NextHeader == IPv6.PROTOCOL_ICMP6) { |
| 568 | ICMP6 icmp6Packet = (ICMP6) ipv6Packet.getPayload(); | 571 | ICMP6 icmp6Packet = (ICMP6) ipv6Packet.getPayload(); |
| 569 | - builder.matchIcmpv6Type(icmp6Packet.getIcmpType()) | 572 | + builder.matchIPProtocol(ipv6NextHeader) |
| 573 | + .matchIcmpv6Type(icmp6Packet.getIcmpType()) | ||
| 570 | .matchIcmpv6Code(icmp6Packet.getIcmpCode()); | 574 | .matchIcmpv6Code(icmp6Packet.getIcmpCode()); |
| 571 | } | 575 | } |
| 572 | } | 576 | } | ... | ... |
-
Please register or login to post a comment