[GEANT] Adaptation to BgpSpeakerVlan feature.
Change-Id: I997bf31778ff41037eab457b338760dc6fdd1582
diff --git a/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3.java b/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3.java
index 8211b68..c28e894 100644
--- a/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3.java
+++ b/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2015 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,23 +21,14 @@
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.onlab.packet.Ethernet;
import org.onosproject.app.ApplicationService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.incubator.component.ComponentService;
import org.onosproject.incubator.net.intf.InterfaceService;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.edge.EdgePortService;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.packet.InboundPacket;
-import org.onosproject.net.packet.PacketContext;
-import org.onosproject.net.packet.PacketProcessor;
import org.onosproject.net.packet.PacketService;
import org.onosproject.routing.IntentSynchronizationAdminService;
import org.onosproject.routing.IntentSynchronizationService;
-import org.onosproject.routing.RoutingService;
-import org.onosproject.routing.config.BgpConfig;
import org.slf4j.Logger;
import java.util.ArrayList;
@@ -49,7 +40,7 @@
* Component for the SDX-L3 application.
*/
@Component(immediate = true)
-public class SdxL3 {
+public class SdxL3 {
public static final String SDX_L3_APP = "org.onosproject.sdxl3";
@@ -62,9 +53,6 @@
protected ApplicationService applicationService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected NetworkConfigService networkConfigService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected InterfaceService interfaceService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -79,16 +67,6 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected PacketService packetService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected EdgePortService edgeService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected HostService hostService;
-
- protected SdxL3ArpHandler arpHandler = null;
-
- private InternalPacketProcessor processor = null;
-
private ApplicationId appId;
private static List<String> components = new ArrayList<>();
@@ -96,57 +74,23 @@
components.add("org.onosproject.routing.bgp.BgpSessionManager");
components.add("org.onosproject.routing.impl.Router");
components.add(org.onosproject.sdxl3.impl.SdxL3PeerManager.class.getName());
- components.add(org.onosproject.sdxl3.SdxL3Fib.class.getName());
+ components.add(SdxL3Fib.class.getName());
+ components.add(SdxL3ArpHandler.class.getName());
}
@Activate
protected void activate() {
components.forEach(name -> componentService.activate(appId, name));
-
appId = coreService.registerApplication(SDX_L3_APP);
-
- ApplicationId routerAppId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
- BgpConfig bgpConfig =
- networkConfigService.getConfig(routerAppId, RoutingService.CONFIG_CLASS);
-
- arpHandler = new SdxL3ArpHandler(bgpConfig,
- edgeService,
- hostService,
- packetService,
- interfaceService);
- processor = new InternalPacketProcessor();
- packetService.addProcessor(processor, PacketProcessor.director(2));
-
// TODO fix removing intents
applicationService.registerDeactivateHook(appId,
intentSynchronizerAdmin::removeIntents);
-
log.info("SDX-L3 started");
}
@Deactivate
protected void deactivate() {
components.forEach(name -> componentService.deactivate(appId, name));
-
- packetService.removeProcessor(processor);
-
log.info("SDX-L3 stopped");
}
-
- private class InternalPacketProcessor implements PacketProcessor {
- @Override
- public void process(PacketContext context) {
-
- if (context.isHandled()) {
- return;
- }
-
- InboundPacket pkt = context.inPacket();
- Ethernet ethernet = pkt.parsed();
- if (ethernet.getEtherType() == Ethernet.TYPE_ARP) {
- arpHandler.processPacketIn(pkt);
- }
- }
- }
-
}
diff --git a/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3ArpHandler.java b/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3ArpHandler.java
index a1643c3..64693ea 100644
--- a/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3ArpHandler.java
+++ b/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3ArpHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,11 @@
*/
package org.onosproject.sdxl3;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.packet.ARP;
import org.onlab.packet.Ethernet;
import org.onlab.packet.ICMP6;
@@ -27,39 +32,68 @@
import org.onlab.packet.ndp.NeighborAdvertisement;
import org.onlab.packet.ndp.NeighborDiscoveryOptions;
import org.onlab.packet.ndp.NeighborSolicitation;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
import org.onosproject.incubator.net.intf.Interface;
import org.onosproject.incubator.net.intf.InterfaceService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Host;
+import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.edge.EdgePortService;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.host.HostService;
import org.onosproject.net.packet.DefaultOutboundPacket;
import org.onosproject.net.packet.InboundPacket;
+import org.onosproject.net.packet.PacketContext;
+import org.onosproject.net.packet.PacketProcessor;
import org.onosproject.net.packet.PacketService;
+import org.onosproject.routing.RoutingService;
import org.onosproject.routing.config.BgpConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.nio.ByteBuffer;
import java.util.Set;
import java.util.stream.Collectors;
-import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.net.HostId.hostId;
import static org.onosproject.security.AppGuard.checkPermission;
import static org.onosproject.security.AppPermission.Type.PACKET_WRITE;
+/**
+ * Proxy-ARP functionality adapted to SDX-L3.
+ */
+@Component(immediate = true, enabled = false)
public class SdxL3ArpHandler {
-
private static final String REQUEST_NULL = "ARP or NDP request cannot be null.";
- private static final String MSG_NOT_REQUEST = "Message is not an ARP or NDP request";
+
+ private Logger log = LoggerFactory.getLogger(getClass());
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected InterfaceService interfaceService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected EdgePortService edgeService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected HostService hostService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected PacketService packetService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected NetworkConfigService networkConfigService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected SdxL3PeerService sdxL3PeerService;
private BgpConfig bgpConfig;
- private EdgePortService edgeService;
- private HostService hostService;
- private PacketService packetService;
- private InterfaceService interfaceService;
+ private InternalPacketProcessor processor = null;
private enum Protocol {
ARP, NDP
@@ -69,20 +103,19 @@
REQUEST, REPLY
}
- /**
- * Creates an ArpHandler object.
- *
- */
- public SdxL3ArpHandler(BgpConfig bgpConfig,
- EdgePortService edgeService,
- HostService hostService,
- PacketService packetService,
- InterfaceService interfaceService) {
- this.bgpConfig = bgpConfig;
- this.edgeService = edgeService;
- this.hostService = hostService;
- this.packetService = packetService;
- this.interfaceService = interfaceService;
+ @Activate
+ public void activate() {
+ ApplicationId routerAppId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
+ bgpConfig = networkConfigService.getConfig(routerAppId, RoutingService.CONFIG_CLASS);
+ processor = new InternalPacketProcessor();
+ packetService.addProcessor(processor, PacketProcessor.director(2));
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ packetService.removeProcessor(processor);
+ log.info("Stopped");
}
/**
@@ -90,7 +123,7 @@
*
* @param pkt incoming packet
*/
- public void processPacketIn(InboundPacket pkt) {
+ protected void processPacketIn(InboundPacket pkt) {
checkPermission(PACKET_WRITE);
Ethernet eth = pkt.parsed();
@@ -99,7 +132,63 @@
ConnectPoint inPort = pkt.receivedFrom();
MessageContext context = createContext(eth, inPort);
if (context != null) {
- replyInternal(context);
+ if (context.type() == MessageType.REQUEST) {
+ handleRequest(context);
+ } else if (context.type() == MessageType.REPLY) {
+ handleReply(context);
+ }
+ }
+ }
+
+ /**
+ * Handles a reply message only in the case it concerns a reply from an
+ * internal speaker to external peer where VLAN translation is necessary.
+ *
+ * @param context reply message context to process
+ */
+ private void handleReply(MessageContext context) {
+ if (fromPeerToSpeaker(context)) {
+ translateVlanAndSendToSpeaker(context);
+ } else if (fromPeerToPeer(context)) {
+ translateVlanAndSendToPeer(context);
+ }
+ }
+
+ private boolean fromPeerToSpeaker(MessageContext context) {
+ return sdxL3PeerService != null &&
+ isPeerAddress(context.sender()) &&
+ !interfaceService.getInterfacesByIp(context.target()).isEmpty();
+ }
+
+ /**
+ * Makes the VLAN translation if necessary and sends the packet at the port
+ * configured for the speaker.
+ *
+ * @param context reply message context to process
+ */
+ private void translateVlanAndSendToSpeaker(MessageContext context) {
+ BgpConfig.BgpSpeakerConfig speaker =
+ bgpConfig.getSpeakerFromPeer(context.sender());
+ if (speaker != null) {
+ Interface peeringInterface = sdxL3PeerService.getInterfaceForPeer(context.sender());
+ if (context.vlan().equals(peeringInterface.vlan())) {
+ context.setVlan(speaker.vlan());
+ sendTo(context.packet(), speaker.connectPoint());
+ }
+ }
+ }
+
+ /**
+ * Makes the VLAN translation if necessary and sends the packet at the port
+ * configured for the peer.
+ *
+ * @param context reply message context to process
+ */
+ private void translateVlanAndSendToPeer(MessageContext context) {
+ Interface interfaceForPeer = sdxL3PeerService.getInterfaceForPeer(context.target());
+ if (interfaceForPeer != null) {
+ context.setVlan(interfaceForPeer.vlan());
+ sendTo(context.packet(), interfaceForPeer.connectPoint());
}
}
@@ -112,22 +201,19 @@
*
* @param context request message context to process
*/
- private void replyInternal(MessageContext context) {
- checkNotNull(context);
- checkArgument(context.type() == MessageType.REQUEST, MSG_NOT_REQUEST);
-
+ private void handleRequest(MessageContext context) {
if (hasIpAddress(context.inPort())) {
// If the request came from outside the network, only reply if it was
// for one of our external addresses.
interfaceService.getInterfacesByPort(context.inPort())
.stream()
- .filter(intf -> intf.ipAddresses()
+ .filter(intf -> intf.ipAddressesList()
.stream()
.anyMatch(ia -> ia.ipAddress().equals(context.target())))
.forEach(intf -> buildAndSendReply(context, intf.mac()));
- if (!isPeerAddress(context.sender()) || !isPeerAddress(context.target())) {
+ if (!fromPeerToPeer(context)) {
// Only care about requests from/towards external BGP peers
return;
}
@@ -139,6 +225,14 @@
Host dst = null;
Host src = hostService.getHost(hostId(context.srcMac(), context.vlan()));
+ // If the request concerns an external BGP peer address and an internal
+ // BGP speaker or is between external BGP peers, VLAN translation may be
+ // necessary on the ARP request.
+ if (fromSpeakerToPeer(context) || fromPeerToPeer(context)) {
+ translateVlanAndSendToPeer(context);
+ return;
+ }
+
for (Host host : hosts) {
if (host.vlan().equals(context.vlan())) {
dst = host;
@@ -189,6 +283,31 @@
flood(context.packet(), context.inPort());
}
+ private boolean fromPeerToPeer(MessageContext context) {
+ return isPeerAddress(context.sender()) && isPeerAddress(context.target());
+ }
+
+ private boolean fromSpeakerToPeer(MessageContext context) {
+ return sdxL3PeerService != null &&
+ isPeerAddress(context.target()) &&
+ !interfaceService.getInterfacesByIp(context.sender()).isEmpty();
+ }
+
+ /**
+ * Makes the VLAN translation if necessary on the packet.
+ *
+ * @param context request message context to process
+ */
+ private VlanId getDestinationPeerVlan(MessageContext context) {
+ return sdxL3PeerService.getInterfaceForPeer(context.target()).vlan();
+ }
+
+ /**
+ * Controls whether an IP address is configured for an external peer.
+ *
+ * @param ip the examined IP address
+ * @return result of the control
+ */
private boolean isPeerAddress(IpAddress ip) {
return bgpConfig.bgpSpeakers()
.stream()
@@ -199,7 +318,7 @@
private Set<Interface> filterVlanInterfacesNoIp(Set<Interface> vlanInterfaces) {
return vlanInterfaces
.stream()
- .filter(intf -> intf.ipAddresses().isEmpty())
+ .filter(intf -> intf.ipAddressesList().isEmpty())
.collect(Collectors.toSet());
}
@@ -215,7 +334,8 @@
Set<Interface> vlanInterfaces = interfaceService.getInterfacesByVlan(vlanId);
return interfaceService.getInterfacesByVlan(vlanId)
.stream()
- .anyMatch(intf -> intf.connectPoint().equals(connectPoint) && intf.ipAddresses().isEmpty())
+ .anyMatch(intf -> intf.connectPoint().equals(connectPoint) &&
+ intf.ipAddressesList().isEmpty())
&& vlanInterfaces.size() > 1;
}
@@ -281,7 +401,7 @@
private boolean hasIpAddress(ConnectPoint connectPoint) {
return interfaceService.getInterfacesByPort(connectPoint)
.stream()
- .flatMap(intf -> intf.ipAddresses().stream())
+ .flatMap(intf -> intf.ipAddressesList().stream())
.findAny()
.isPresent();
}
@@ -302,7 +422,7 @@
}
/**
- * Flood the arp request at all edges on a specifc VLAN.
+ * Floods the arp request at all edges on a specifc VLAN.
*
* @param request the arp request
* @param dsts the destination interfaces
@@ -457,7 +577,7 @@
ICMP6 icmpv6 = (ICMP6) ipv6.getPayload();
IpAddress sender = Ip6Address.valueOf(ipv6.getSourceAddress());
- IpAddress target = null;
+ IpAddress target = Ip6Address.valueOf(ipv6.getDestinationAddress());
MessageType type;
if (icmpv6.getIcmpType() == ICMP6.NEIGHBOR_SOLICITATION) {
@@ -530,6 +650,26 @@
public IpAddress sender() {
return sender;
}
+
+ public void setVlan(VlanId vlanId) {
+ this.eth.setVlanID(vlanId.toShort());
+ }
+ }
+
+ private class InternalPacketProcessor implements PacketProcessor {
+ @Override
+ public void process(PacketContext context) {
+
+ if (context.isHandled()) {
+ return;
+ }
+
+ InboundPacket pkt = context.inPacket();
+ Ethernet ethernet = pkt.parsed();
+ if (ethernet.getEtherType() == Ethernet.TYPE_ARP) {
+ processPacketIn(pkt);
+ }
+ }
}
}
diff --git a/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3Fib.java b/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3Fib.java
index 9cd228d..2a64240 100644
--- a/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3Fib.java
+++ b/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3Fib.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2015 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3PeerService.java b/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3PeerService.java
index c0a7a77..9b8e2d2 100644
--- a/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3PeerService.java
+++ b/sdx-l3/src/main/java/org/onosproject/sdxl3/SdxL3PeerService.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
import org.onosproject.incubator.net.intf.Interface;
import org.onosproject.net.ConnectPoint;
import org.onosproject.routing.config.BgpConfig;
-import org.onosproject.sdxl3.config.SdxProvidersConfig;
+import org.onosproject.sdxl3.config.SdxParticipantsConfig;
import java.util.List;
@@ -29,8 +29,8 @@
*/
public interface SdxL3PeerService {
- Class<SdxProvidersConfig> CONFIG_CLASS = SdxProvidersConfig.class;
- String CONFIG_KEY = "providers";
+ Class<SdxParticipantsConfig> CONFIG_CLASS = SdxParticipantsConfig.class;
+ String CONFIG_KEY = "participants";
/**
* Returns the list of IP addresses of BGP peers.
diff --git a/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/AddPeerDetailsCommand.java b/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/AddPeerDetailsCommand.java
index acc4579..dae6b49 100644
--- a/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/AddPeerDetailsCommand.java
+++ b/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/AddPeerDetailsCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/BgpPeersListCommand.java b/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/BgpPeersListCommand.java
index 2e22bed..b50c2e2 100644
--- a/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/BgpPeersListCommand.java
+++ b/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/BgpPeersListCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2015 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@
import org.onosproject.routing.config.BgpConfig;
import org.onosproject.sdxl3.SdxL3;
import org.onosproject.sdxl3.SdxL3PeerService;
-import org.onosproject.sdxl3.config.SdxProvidersConfig;
+import org.onosproject.sdxl3.config.SdxParticipantsConfig;
import java.util.Comparator;
import java.util.List;
@@ -46,7 +46,7 @@
private static final String NAME_FORMAT = "%s: " + DETAILS_FORMAT;
public static final String NO_PEERS = "No peers configured";
- private static final Comparator<SdxProvidersConfig.PeerConfig> PEER_COMPARATOR =
+ private static final Comparator<SdxParticipantsConfig.PeerConfig> PEER_COMPARATOR =
Comparator.comparing(p -> p.ip());
public static final String EMPTY = "";
@@ -60,8 +60,8 @@
BgpConfig bgpConfig = configService.getConfig(routerAppId, RoutingService.CONFIG_CLASS);
ApplicationId sdxL3AppId = coreService.getAppId(SdxL3.SDX_L3_APP);
- SdxProvidersConfig peersConfig = configService.
- getConfig(sdxL3AppId, SdxProvidersConfig.class);
+ SdxParticipantsConfig peersConfig = configService.
+ getConfig(sdxL3AppId, SdxParticipantsConfig.class);
if (bgpConfig == null && peersConfig == null) {
print(NO_PEERS);
@@ -74,7 +74,7 @@
peeringAddresses = peerService.getPeerAddresses(bgpConfig);
}
- List<SdxProvidersConfig.PeerConfig> bgpPeers =
+ List<SdxParticipantsConfig.PeerConfig> bgpPeers =
Lists.newArrayList();
if (peersConfig != null) {
// Get all peers having details specified
@@ -103,15 +103,15 @@
});
}
- private List<SdxProvidersConfig.PeerConfig> mergePeers(
+ private List<SdxParticipantsConfig.PeerConfig> mergePeers(
List<IpAddress> peeringAddresses,
- List<SdxProvidersConfig.PeerConfig> bgpPeers) {
+ List<SdxParticipantsConfig.PeerConfig> bgpPeers) {
peeringAddresses.forEach(a -> {
boolean exists = bgpPeers.stream()
.filter(p -> p.ip().equals(a))
.findAny().isPresent();
if (!exists) {
- bgpPeers.add(new SdxProvidersConfig
+ bgpPeers.add(new SdxParticipantsConfig
.PeerConfig(Optional.<String>empty(), a, null, EMPTY));
}
});
diff --git a/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/RemovePeerDetailsCommand.java b/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/RemovePeerDetailsCommand.java
index 8eee2ba..a8e1bb9 100644
--- a/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/RemovePeerDetailsCommand.java
+++ b/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/RemovePeerDetailsCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/package-info.java b/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/package-info.java
index a5216de..0aa9aed 100644
--- a/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/package-info.java
+++ b/sdx-l3/src/main/java/org/onosproject/sdxl3/cli/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2015 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/sdx-l3/src/main/java/org/onosproject/sdxl3/config/SdxProvidersConfig.java b/sdx-l3/src/main/java/org/onosproject/sdxl3/config/SdxParticipantsConfig.java
similarity index 98%
rename from sdx-l3/src/main/java/org/onosproject/sdxl3/config/SdxProvidersConfig.java
rename to sdx-l3/src/main/java/org/onosproject/sdxl3/config/SdxParticipantsConfig.java
index 8206fda..6d3dfce 100644
--- a/sdx-l3/src/main/java/org/onosproject/sdxl3/config/SdxProvidersConfig.java
+++ b/sdx-l3/src/main/java/org/onosproject/sdxl3/config/SdxParticipantsConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2015 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@
* Configuration for the Service Providers being connected to the
* software defined internet exchange point.
*/
-public class SdxProvidersConfig extends Config<ApplicationId> {
+public class SdxParticipantsConfig extends Config<ApplicationId> {
public static final String PEERS = "bgpPeers";
public static final String NAME = "name";
diff --git a/sdx-l3/src/main/java/org/onosproject/sdxl3/config/package-info.java b/sdx-l3/src/main/java/org/onosproject/sdxl3/config/package-info.java
index ebcfa19..14c6552 100644
--- a/sdx-l3/src/main/java/org/onosproject/sdxl3/config/package-info.java
+++ b/sdx-l3/src/main/java/org/onosproject/sdxl3/config/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2015 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/sdx-l3/src/main/java/org/onosproject/sdxl3/impl/SdxL3PeerManager.java b/sdx-l3/src/main/java/org/onosproject/sdxl3/impl/SdxL3PeerManager.java
index dfa68ba..e9105a3 100644
--- a/sdx-l3/src/main/java/org/onosproject/sdxl3/impl/SdxL3PeerManager.java
+++ b/sdx-l3/src/main/java/org/onosproject/sdxl3/impl/SdxL3PeerManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.TpPort;
+import org.onlab.packet.VlanId;
import org.onlab.util.ItemNotFoundException;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
@@ -54,7 +55,7 @@
import org.onosproject.routing.config.BgpConfig;
import org.onosproject.sdxl3.SdxL3;
import org.onosproject.sdxl3.SdxL3PeerService;
-import org.onosproject.sdxl3.config.SdxProvidersConfig;
+import org.onosproject.sdxl3.config.SdxParticipantsConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -103,8 +104,8 @@
new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY,
CONFIG_CLASS, CONFIG_KEY) {
@Override
- public SdxProvidersConfig createConfig() {
- return new SdxProvidersConfig();
+ public SdxParticipantsConfig createConfig() {
+ return new SdxParticipantsConfig();
}
};
@@ -146,7 +147,10 @@
* @param interfaceName Name of the interface configured on port
*/
@Override
- public void addPeerDetails(String peerName, IpAddress peerAddress, ConnectPoint port, String interfaceName) {
+ public void addPeerDetails(String peerName,
+ IpAddress peerAddress,
+ ConnectPoint port,
+ String interfaceName) {
BgpConfig bgpConfig = getBgpConfig();
if (bgpConfig == null) {
@@ -178,15 +182,15 @@
}
}
- SdxProvidersConfig peersConfig =
- configService.addConfig(sdxAppId, SdxProvidersConfig.class);
+ SdxParticipantsConfig peersConfig =
+ configService.addConfig(sdxAppId, SdxParticipantsConfig.class);
if (peerName != null && peerNameExists(peersConfig, peerName)) {
throw new IllegalArgumentException("Peer name in use");
}
addPeerToConf(peersConfig, peerName, peerAddress, port, interfaceName);
configService.
- applyConfig(sdxAppId, SdxProvidersConfig.class, peersConfig.node());
+ applyConfig(sdxAppId, SdxParticipantsConfig.class, peersConfig.node());
}
/**
@@ -201,8 +205,8 @@
throw new ItemNotFoundException("BGP configuration not found");
}
- SdxProvidersConfig peersConfig =
- configService.addConfig(sdxAppId, SdxProvidersConfig.class);
+ SdxParticipantsConfig peersConfig =
+ configService.addConfig(sdxAppId, SdxParticipantsConfig.class);
if (peersConfig.getPeerForIp(peerAddress) == null) {
throw new ItemNotFoundException("Peer details not found");
@@ -210,7 +214,7 @@
removePeerFromConf(peersConfig, peerAddress);
configService.applyConfig(sdxAppId,
- SdxProvidersConfig.class,
+ SdxParticipantsConfig.class,
peersConfig.node());
}
@@ -244,7 +248,7 @@
}
private boolean interfaceSubnetIncludesIp(Interface peerInterface, IpAddress peerAddress) {
- if (peerInterface.ipAddresses().stream()
+ if (peerInterface.ipAddressesList().stream()
.anyMatch(intfIp -> intfIp.subnetAddress().
contains(peerAddress))) {
// Interface configured subnet not including peer address
@@ -253,7 +257,7 @@
return false;
}
- private boolean peerNameExists(SdxProvidersConfig config, String peerName) {
+ private boolean peerNameExists(SdxParticipantsConfig config, String peerName) {
if (config.getPeerForName(Optional.of(peerName)) == null) {
return false;
}
@@ -265,11 +269,11 @@
*
* @param peersConfig the BGP peers configuration
*/
- private void addPeerToConf(SdxProvidersConfig peersConfig, String peerName,
+ private void addPeerToConf(SdxParticipantsConfig peersConfig, String peerName,
IpAddress peerAddress, ConnectPoint port,
String interfaceName) {
log.debug("Adding peer with IP to configuration: {}", peerAddress);
- SdxProvidersConfig.PeerConfig peer = new SdxProvidersConfig.
+ SdxParticipantsConfig.PeerConfig peer = new SdxParticipantsConfig.
PeerConfig(Optional.ofNullable(peerName), peerAddress,
port, interfaceName);
@@ -281,7 +285,7 @@
*
* @param peersConfig the BGP peeers configuration
*/
- private void removePeerFromConf(SdxProvidersConfig peersConfig,
+ private void removePeerFromConf(SdxParticipantsConfig peersConfig,
IpAddress peerAddress) {
log.debug("Removing peer details from configuration: {}",
peerAddress.toString());
@@ -311,7 +315,7 @@
return null;
}
- SdxProvidersConfig config = configService.getConfig(sdxAppId, SdxProvidersConfig.class);
+ SdxParticipantsConfig config = configService.getConfig(sdxAppId, SdxParticipantsConfig.class);
if (config == null) {
return null;
}
@@ -395,6 +399,9 @@
private Collection<PointToPointIntent> buildSpeakerIntents(BgpConfig.BgpSpeakerConfig speaker) {
List<PointToPointIntent> intents = new ArrayList<>();
+ // Get the BGP Speaker VLAN Id
+ VlanId bgpSpeakerVlanId = speaker.vlan();
+
for (IpAddress peerAddress : speaker.peers()) {
Interface peeringInterface = getInterfaceForPeer(peerAddress);
@@ -404,18 +411,23 @@
continue;
}
- IpAddress peeringAddress = null;
- for (InterfaceIpAddress address : peeringInterface.ipAddresses()) {
+ IpAddress bgpSpeakerAddress = null;
+ for (InterfaceIpAddress address : peeringInterface.ipAddressesList()) {
if (address.subnetAddress().contains(peerAddress)) {
- peeringAddress = address.ipAddress();
+ bgpSpeakerAddress = address.ipAddress();
break;
}
}
- checkNotNull(peeringAddress);
+ checkNotNull(bgpSpeakerAddress);
- intents.addAll(buildIntents(speaker.connectPoint(), peeringAddress,
- peeringInterface.connectPoint(), peerAddress));
+ VlanId peerVlanId = peeringInterface.vlan();
+
+ intents.addAll(buildIntents(speaker.connectPoint(), bgpSpeakerVlanId,
+ bgpSpeakerAddress,
+ peeringInterface.connectPoint(),
+ peerVlanId,
+ peerAddress));
}
return intents;
@@ -426,19 +438,24 @@
* IP addresses.
*
* @param portOne the first connect point
+ * @param vlanOne the ingress VLAN
* @param ipOne the first IP address
* @param portTwo the second connect point
+ * @param vlanTwo the egress VLAN
* @param ipTwo the second IP address
* @return the intents to install
*/
private Collection<PointToPointIntent> buildIntents(ConnectPoint portOne,
+ VlanId vlanOne,
IpAddress ipOne,
ConnectPoint portTwo,
+ VlanId vlanTwo,
IpAddress ipTwo) {
List<PointToPointIntent> intents = new ArrayList<>();
- TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
+ TrafficTreatment.Builder treatmentToPeer = DefaultTrafficTreatment.builder();
+ TrafficTreatment.Builder treatmentToSpeaker = DefaultTrafficTreatment.builder();
TrafficSelector selector;
Key key;
@@ -453,8 +470,14 @@
icmpProtocol = IPv6.PROTOCOL_ICMP6;
}
- // Path from BGP speaker to BGP peer matching destination TCP connectPoint 179
+ // Add treatment for VLAN for traffic going from BGP speaker to BGP peer
+ if (!vlanTwo.equals(VlanId.NONE)) {
+ treatmentToPeer.setVlanId(vlanTwo);
+ }
+
+ // Path from BGP speaker to BGP peer matching destination TCP port 179
selector = buildSelector(tcpProtocol,
+ vlanOne,
ipOne,
ipTwo,
null,
@@ -466,14 +489,15 @@
.appId(sdxAppId)
.key(key)
.selector(selector)
- .treatment(treatment)
+ .treatment(treatmentToPeer.build())
.ingressPoint(portOne)
.egressPoint(portTwo)
.priority(PRIORITY_OFFSET)
.build());
- // Path from BGP speaker to BGP peer matching source TCP connectPoint 179
+ // Path from BGP speaker to BGP peer matching source TCP port 179
selector = buildSelector(tcpProtocol,
+ vlanOne,
ipOne,
ipTwo,
BGP_PORT,
@@ -485,52 +509,15 @@
.appId(sdxAppId)
.key(key)
.selector(selector)
- .treatment(treatment)
+ .treatment(treatmentToPeer.build())
.ingressPoint(portOne)
.egressPoint(portTwo)
.priority(PRIORITY_OFFSET)
.build());
- // Path from BGP peer to BGP speaker matching destination TCP connectPoint 179
- selector = buildSelector(tcpProtocol,
- ipTwo,
- ipOne,
- null,
- BGP_PORT);
-
- key = buildKey(ipTwo, ipOne, SUFFIX_DST);
-
- intents.add(PointToPointIntent.builder()
- .appId(sdxAppId)
- .key(key)
- .selector(selector)
- .treatment(treatment)
- .ingressPoint(portTwo)
- .egressPoint(portOne)
- .priority(PRIORITY_OFFSET)
- .build());
-
- // Path from BGP peer to BGP speaker matching source TCP connectPoint 179
- selector = buildSelector(tcpProtocol,
- ipTwo,
- ipOne,
- BGP_PORT,
- null);
-
- key = buildKey(ipTwo, ipOne, SUFFIX_SRC);
-
- intents.add(PointToPointIntent.builder()
- .appId(sdxAppId)
- .key(key)
- .selector(selector)
- .treatment(treatment)
- .ingressPoint(portTwo)
- .egressPoint(portOne)
- .priority(PRIORITY_OFFSET)
- .build());
-
// ICMP path from BGP speaker to BGP peer
selector = buildSelector(icmpProtocol,
+ vlanOne,
ipOne,
ipTwo,
null,
@@ -542,14 +529,60 @@
.appId(sdxAppId)
.key(key)
.selector(selector)
- .treatment(treatment)
+ .treatment(treatmentToPeer.build())
.ingressPoint(portOne)
.egressPoint(portTwo)
.priority(PRIORITY_OFFSET)
.build());
+ // Add treatment for VLAN for traffic going from BGP peer to BGP speaker
+ if (!vlanOne.equals(VlanId.NONE)) {
+ treatmentToSpeaker.setVlanId(vlanOne);
+ }
+
+ // Path from BGP peer to BGP speaker matching destination TCP port 179
+ selector = buildSelector(tcpProtocol,
+ vlanTwo,
+ ipTwo,
+ ipOne,
+ null,
+ BGP_PORT);
+
+ key = buildKey(ipTwo, ipOne, SUFFIX_DST);
+
+ intents.add(PointToPointIntent.builder()
+ .appId(sdxAppId)
+ .key(key)
+ .selector(selector)
+ .treatment(treatmentToSpeaker.build())
+ .ingressPoint(portTwo)
+ .egressPoint(portOne)
+ .priority(PRIORITY_OFFSET)
+ .build());
+
+ // Path from BGP peer to BGP speaker matching source TCP port 179
+ selector = buildSelector(tcpProtocol,
+ vlanTwo,
+ ipTwo,
+ ipOne,
+ BGP_PORT,
+ null);
+
+ key = buildKey(ipTwo, ipOne, SUFFIX_SRC);
+
+ intents.add(PointToPointIntent.builder()
+ .appId(sdxAppId)
+ .key(key)
+ .selector(selector)
+ .treatment(treatmentToSpeaker.build())
+ .ingressPoint(portTwo)
+ .egressPoint(portOne)
+ .priority(PRIORITY_OFFSET)
+ .build());
+
// ICMP path from BGP peer to BGP speaker
selector = buildSelector(icmpProtocol,
+ vlanTwo,
ipTwo,
ipOne,
null,
@@ -561,7 +594,7 @@
.appId(sdxAppId)
.key(key)
.selector(selector)
- .treatment(treatment)
+ .treatment(treatmentToSpeaker.build())
.ingressPoint(portTwo)
.egressPoint(portOne)
.priority(PRIORITY_OFFSET)
@@ -574,16 +607,23 @@
* Builds a traffic selector based on the set of input parameters.
*
* @param ipProto IP protocol
+ * @param ingressVlanId VLAN Id configured on the ingress interface
* @param srcIp source IP address
* @param dstIp destination IP address
- * @param srcTcpPort source TCP connectPoint, or null if shouldn't be set
- * @param dstTcpPort destination TCP connectPoint, or null if shouldn't be set
+ * @param srcTcpPort source TCP port, or null if shouldn't be set
+ * @param dstTcpPort destination TCP port, or null if shouldn't be set
* @return the new traffic selector
*/
- private TrafficSelector buildSelector(byte ipProto, IpAddress srcIp,
+ private TrafficSelector buildSelector(byte ipProto,
+ VlanId ingressVlanId,
+ IpAddress srcIp,
IpAddress dstIp, Short srcTcpPort,
Short dstTcpPort) {
TrafficSelector.Builder builder = DefaultTrafficSelector.builder().matchIPProtocol(ipProto);
+ // Match on any VLAN Id if a VLAN Id configured on the ingress interface
+ if (!ingressVlanId.equals(VlanId.NONE)) {
+ builder.matchVlanId(VlanId.ANY);
+ }
if (dstIp.isIp4()) {
builder.matchEthType(Ethernet.TYPE_IPV4)
diff --git a/sdx-l3/src/main/java/org/onosproject/sdxl3/impl/package-info.java b/sdx-l3/src/main/java/org/onosproject/sdxl3/impl/package-info.java
index d172822..81773cb 100644
--- a/sdx-l3/src/main/java/org/onosproject/sdxl3/impl/package-info.java
+++ b/sdx-l3/src/main/java/org/onosproject/sdxl3/impl/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/sdx-l3/src/main/java/org/onosproject/sdxl3/package-info.java b/sdx-l3/src/main/java/org/onosproject/sdxl3/package-info.java
index eb7b599..6869796 100644
--- a/sdx-l3/src/main/java/org/onosproject/sdxl3/package-info.java
+++ b/sdx-l3/src/main/java/org/onosproject/sdxl3/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2015 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/sdx-l3/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/sdx-l3/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index 237a9dc..6c3a84d 100644
--- a/sdx-l3/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/sdx-l3/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -1,5 +1,5 @@
<!--
- ~ Copyright 2014-2015 Open Networking Laboratory
+ ~ Copyright 2016-present Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
diff --git a/sdx-l3/src/main/resources/config-examples/network-cfg.json b/sdx-l3/src/main/resources/config-examples/network-cfg.json
index 7100e7a..31fde3f 100644
--- a/sdx-l3/src/main/resources/config-examples/network-cfg.json
+++ b/sdx-l3/src/main/resources/config-examples/network-cfg.json
@@ -50,7 +50,7 @@
},
"apps" : {
"org.onosproject.sdxl3": {
- "providers": {
+ "participants": {
"bgpPeers": [
{
"name": "AS1-Router1",
diff --git a/sdx-l3/src/main/resources/config-examples/route-server_network-cfg.json b/sdx-l3/src/main/resources/config-examples/route-server_network-cfg.json
index 1bdc232..e4df2f8 100644
--- a/sdx-l3/src/main/resources/config-examples/route-server_network-cfg.json
+++ b/sdx-l3/src/main/resources/config-examples/route-server_network-cfg.json
@@ -21,7 +21,7 @@
},
"apps" : {
"org.onosproject.sdxl3" : {
- "providers" : {
+ "participants" : {
"bgpPeers": [
{
"name": "AS65001-R1",