Class DefaultGroupHandler
- java.lang.Object
-
- org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler
-
- Direct Known Subclasses:
PolicyGroupHandler
public class DefaultGroupHandler extends Object
Default ECMP group handler creation module. This component creates a set of ECMP groups for every neighbor that this device is connected to based on whether the current device is an edge device or a transit device.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classDefaultGroupHandler.BucketCorrectorPerforms bucket verification operation for all hash groups in this device.
-
Field Summary
Fields Modifier and Type Field Description protected List<Integer>allSegmentIdsprotected org.onosproject.core.ApplicationIdappIdprotected org.onosproject.segmentrouting.config.DevicePropertiesdeviceConfigprotected org.onosproject.net.DeviceIddeviceIdprotected ConcurrentHashMap<org.onosproject.net.DeviceId,Set<org.onosproject.net.PortNumber>>devicePortMaplocal store for neighbor-device-ids and the set of ports on this device that connect to the same neighbor.protected org.onosproject.store.service.EventuallyConsistentMap<DestinationSetNextObjectiveStoreKey,NextNeighbors>dsNextObjStoreprotected org.onosproject.net.flowobjective.FlowObjectiveServiceflowObjectiveServiceprotected intipv4NodeSegmentIdprotected intipv6NodeSegmentIdprotected booleanisEdgeRouterprotected org.onlab.util.KryoNamespace.Builderkryoprotected org.onosproject.net.link.LinkServicelinkServiceprotected org.onosproject.store.service.EventuallyConsistentMap<MacVlanNextObjectiveStoreKey,Integer>macVlanNextObjStoreprotected org.onlab.packet.MacAddressnodeMacAddrprotected ConcurrentHashMap<org.onosproject.net.PortNumber,org.onosproject.net.DeviceId>portDeviceMaplocal store for ports on this device connected to neighbor-device-id.protected org.onosproject.store.service.EventuallyConsistentMap<PortNextObjectiveStoreKey,Integer>portNextObjStoreprotected org.onosproject.store.service.EventuallyConsistentMap<VlanNextObjectiveStoreKey,Integer>vlanNextObjStore
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultGroupHandler(org.onosproject.net.DeviceId deviceId, org.onosproject.core.ApplicationId appId, org.onosproject.segmentrouting.config.DeviceProperties config, org.onosproject.net.link.LinkService linkService, org.onosproject.net.flowobjective.FlowObjectiveService flowObjService, SegmentRoutingManager srManager)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddNeighborAtPort(org.onosproject.net.DeviceId neighborId, org.onosproject.net.PortNumber portToNeighbor)voidcleanUpForNeighborDown(org.onosproject.net.DeviceId neighborId)Cleans up local stores for removed neighbor device.voidcreateBcastGroupFromVlan(org.onlab.packet.VlanId vlanId, Collection<org.onosproject.net.PortNumber> ports)Creates a single broadcast group from a given vlan id and list of ports.voidcreateGroupFromDestinationSet(DestinationSet ds, Map<org.onosproject.net.DeviceId,Set<org.onosproject.net.DeviceId>> neighbors, org.onosproject.net.flow.TrafficSelector meta, boolean simple)Creates a NextObjective for a hash group in this device from a given DestinationSet.intcreateGroupFromMacVlan(org.onlab.packet.MacAddress macAddr, org.onlab.packet.VlanId vlanId, org.onosproject.net.flow.TrafficTreatment treatment, org.onosproject.net.flow.TrafficSelector meta)Create simple next objective for an indirect host mac/vlan.voidcreateGroupFromPort(org.onosproject.net.PortNumber portNum, org.onosproject.net.flow.TrafficTreatment treatment, org.onosproject.net.flow.TrafficSelector meta)Create simple next objective for a single port.static DefaultGroupHandlercreateGroupHandler(org.onosproject.net.DeviceId deviceId, org.onosproject.core.ApplicationId appId, org.onosproject.segmentrouting.config.DeviceProperties config, org.onosproject.net.link.LinkService linkService, org.onosproject.net.flowobjective.FlowObjectiveService flowObjService, SegmentRoutingManager srManager)Creates a group handler object.voidcreateGroupsFromVlanConfig()Creates broadcast groups for all ports in the same subnet for all configured subnets.voidcreatePortNextObjective(org.onosproject.net.DeviceId deviceId, org.onosproject.net.PortNumber portNum, org.onlab.packet.VlanId vlanId, boolean popVlan)Creates simple next objective for a single port.booleanfixHashGroups(org.onosproject.net.DeviceId targetSw, Set<org.onosproject.net.DeviceId> nextHops, org.onosproject.net.DeviceId destSw, boolean revoke)Checks all the hash-groups in the target-switch meant for the destination switch, and either adds or removes buckets to make the neighbor-set match the given next-hops.intgetMacVlanNextObjectiveId(org.onlab.packet.MacAddress macAddr, org.onlab.packet.VlanId vlanId, org.onosproject.net.PortNumber port, boolean createIfMissing)Returns the next objective of type simple associated with the mac/vlan on the device, given the treatment.intgetNextObjectiveId(DestinationSet ds, Map<org.onosproject.net.DeviceId,Set<org.onosproject.net.DeviceId>> nextHops, org.onosproject.net.flow.TrafficSelector meta, boolean simple)Returns the next objective of type hashed (or simple) associated with the destination set.intgetPortNextObjectiveId(org.onosproject.net.PortNumber portNum, org.onosproject.net.flow.TrafficTreatment treatment, org.onosproject.net.flow.TrafficSelector meta, boolean createIfMissing)Returns the next objective of type simple associated with the port on the device, given the treatment.intgetVlanNextObjectiveId(org.onlab.packet.VlanId vlanId)Returns the next objective of type broadcast associated with the vlan, or -1 if no such objective exists.booleanhasNextObjectiveId(DestinationSet ns)Checks if the next objective ID (group) for the neighbor set exists or not.voidportDownForLink(org.onosproject.net.Link link)Updates local stores for link-src-device/port to neighbor (link-dst) for link that has gone down.voidportUpForLink(org.onosproject.net.Link link)Updates local stores for link-src-device/port to neighbor (link-dst) for link that has come up.voidprocessEdgePort(org.onosproject.net.PortNumber port, org.onlab.packet.VlanId vlanId, boolean popVlan, boolean portUp)Adds or removes a port that has been configured with a vlan to a broadcast group for bridging.voidremoveBcastGroupFromVlan(org.onosproject.net.DeviceId deviceId, org.onosproject.net.PortNumber portNum, org.onlab.packet.VlanId vlanId, boolean popVlan)Removes a single broadcast group from a given vlan id.booleanremoveGroup(int objectiveId)Removes groups for the next objective ID given.CompletableFuture<org.onosproject.net.flowobjective.Objective>removeGroupFromPort(org.onosproject.net.PortNumber portNum, org.onosproject.net.flow.TrafficTreatment treatment, org.onosproject.net.flow.TrafficSelector meta)Remove simple next objective for a single port.voidremovePortNextObjective(org.onosproject.net.DeviceId deviceId, org.onosproject.net.PortNumber portNum, org.onlab.packet.VlanId vlanId, boolean popVlan)Removes simple next objective for a single port.voidretryHash(org.onosproject.net.Link link, boolean linkDown, boolean firstTime)Checks all groups in the src-device of link for neighbor sets that include the dst-device of link, and edits the hash groups according to link up or down.voidshutdown()Gracefully shuts down a groupHandler.voidtriggerBucketCorrector()Triggers a one time bucket verification operation on all hash groups on this device.voidupdateGroupFromVlanConfiguration(org.onlab.packet.VlanId vlanId, org.onosproject.net.PortNumber portNum, int nextId, boolean install)Adds a single port to the L2FG or removes it from the L2FG.voidupdateL2InterfaceGroupBucket(org.onosproject.net.PortNumber portNumber, org.onlab.packet.VlanId vlanId, boolean pushVlan)Modifies L2IG bucket when the interface configuration is updated, especially when the interface has same VLAN ID but the VLAN type is changed (e.g., from vlan-tagged [10] to vlan-untagged 10), which requires changes on TrafficTreatment in turn.voidupdateL3UcastGroupBucket(org.onlab.packet.MacAddress hostMac, org.onlab.packet.VlanId hostVlanId, org.onosproject.net.PortNumber port, int nextId)Updates the next objective for the given nextId .
-
-
-
Field Detail
-
deviceId
protected final org.onosproject.net.DeviceId deviceId
-
appId
protected final org.onosproject.core.ApplicationId appId
-
deviceConfig
protected final org.onosproject.segmentrouting.config.DeviceProperties deviceConfig
-
ipv4NodeSegmentId
protected int ipv4NodeSegmentId
-
ipv6NodeSegmentId
protected int ipv6NodeSegmentId
-
isEdgeRouter
protected boolean isEdgeRouter
-
nodeMacAddr
protected org.onlab.packet.MacAddress nodeMacAddr
-
linkService
protected org.onosproject.net.link.LinkService linkService
-
flowObjectiveService
protected org.onosproject.net.flowobjective.FlowObjectiveService flowObjectiveService
-
devicePortMap
protected ConcurrentHashMap<org.onosproject.net.DeviceId,Set<org.onosproject.net.PortNumber>> devicePortMap
local store for neighbor-device-ids and the set of ports on this device that connect to the same neighbor.
-
portDeviceMap
protected ConcurrentHashMap<org.onosproject.net.PortNumber,org.onosproject.net.DeviceId> portDeviceMap
local store for ports on this device connected to neighbor-device-id.
-
dsNextObjStore
protected org.onosproject.store.service.EventuallyConsistentMap<DestinationSetNextObjectiveStoreKey,NextNeighbors> dsNextObjStore
-
vlanNextObjStore
protected org.onosproject.store.service.EventuallyConsistentMap<VlanNextObjectiveStoreKey,Integer> vlanNextObjStore
-
macVlanNextObjStore
protected org.onosproject.store.service.EventuallyConsistentMap<MacVlanNextObjectiveStoreKey,Integer> macVlanNextObjStore
-
portNextObjStore
protected org.onosproject.store.service.EventuallyConsistentMap<PortNextObjectiveStoreKey,Integer> portNextObjStore
-
kryo
protected org.onlab.util.KryoNamespace.Builder kryo
-
-
Constructor Detail
-
DefaultGroupHandler
protected DefaultGroupHandler(org.onosproject.net.DeviceId deviceId, org.onosproject.core.ApplicationId appId, org.onosproject.segmentrouting.config.DeviceProperties config, org.onosproject.net.link.LinkService linkService, org.onosproject.net.flowobjective.FlowObjectiveService flowObjService, SegmentRoutingManager srManager)
-
-
Method Detail
-
shutdown
public void shutdown()
Gracefully shuts down a groupHandler. Typically called when the handler is no longer needed.
-
createGroupHandler
public static DefaultGroupHandler createGroupHandler(org.onosproject.net.DeviceId deviceId, org.onosproject.core.ApplicationId appId, org.onosproject.segmentrouting.config.DeviceProperties config, org.onosproject.net.link.LinkService linkService, org.onosproject.net.flowobjective.FlowObjectiveService flowObjService, SegmentRoutingManager srManager) throws org.onosproject.segmentrouting.config.DeviceConfigNotFoundException
Creates a group handler object.- Parameters:
deviceId- device identifierappId- application identifierconfig- interface to retrieve the device propertieslinkService- link service objectflowObjService- flow objective service objectsrManager- segment routing manager- Returns:
- default group handler type
- Throws:
org.onosproject.segmentrouting.config.DeviceConfigNotFoundException- if the device configuration is not found
-
portUpForLink
public void portUpForLink(org.onosproject.net.Link link)
Updates local stores for link-src-device/port to neighbor (link-dst) for link that has come up.- Parameters:
link- the infrastructure link
-
portDownForLink
public void portDownForLink(org.onosproject.net.Link link)
Updates local stores for link-src-device/port to neighbor (link-dst) for link that has gone down.- Parameters:
link- the infrastructure link
-
cleanUpForNeighborDown
public void cleanUpForNeighborDown(org.onosproject.net.DeviceId neighborId)
Cleans up local stores for removed neighbor device.- Parameters:
neighborId- the device identifier for the neighbor device
-
retryHash
public void retryHash(org.onosproject.net.Link link, boolean linkDown, boolean firstTime)Checks all groups in the src-device of link for neighbor sets that include the dst-device of link, and edits the hash groups according to link up or down. Should only be called by the instance leading the programming of the src-switch of link. Typically used when there are no route-path changes due to the link up or down, as the ECMPspg does not change.- Parameters:
link- the infrastructure link that has gone down or come uplinkDown- true if link has gone downfirstTime- true if link has come up for the first time i.e a link not seen-before
-
fixHashGroups
public boolean fixHashGroups(org.onosproject.net.DeviceId targetSw, Set<org.onosproject.net.DeviceId> nextHops, org.onosproject.net.DeviceId destSw, boolean revoke)Checks all the hash-groups in the target-switch meant for the destination switch, and either adds or removes buckets to make the neighbor-set match the given next-hops. Typically called by the instance leading the programming of the destination switch, which may be different from the instance leading the programming of the target switch where hash-group changes are made.- Parameters:
targetSw- the switch in which the hash groups will be editednextHops- the current next hops for the target switch to reach the dest swdestSw- the destination switchrevoke- true if hash groups need to remove buckets from the the groups to match the current next hops- Returns:
- true if calls are made to edit buckets, or if no edits are required
-
processEdgePort
public void processEdgePort(org.onosproject.net.PortNumber port, org.onlab.packet.VlanId vlanId, boolean popVlan, boolean portUp)Adds or removes a port that has been configured with a vlan to a broadcast group for bridging. Should only be called by the instance leading the programming for this device.- Parameters:
port- the port on this device that needs to be added/removed to a bcast groupvlanId- the vlan id corresponding to the broadcast domain/grouppopVlan- indicates if packets should be sent out untagged or not out of the port. If true, indicates an access (untagged) or native vlan configuration. If false, indicates a trunk (tagged) vlan config.portUp- true if port is enabled, false if disabled
-
getNextObjectiveId
public int getNextObjectiveId(DestinationSet ds, Map<org.onosproject.net.DeviceId,Set<org.onosproject.net.DeviceId>> nextHops, org.onosproject.net.flow.TrafficSelector meta, boolean simple)
Returns the next objective of type hashed (or simple) associated with the destination set. In addition, updates the existing next-objective if new route-paths found have resulted in the addition of new next-hops to a particular destination. If there is no existing next objective for this destination set, this method would create a next objective and return the nextId. Optionally metadata can be passed in for the creation of the next objective. If the parameter simple is true then a simple next objective is created instead of a hashed one.- Parameters:
ds- destination setnextHops- a map of per destination next hopsmeta- metadata passed into the creation of a Next Objectivesimple- if true, a simple next objective will be created instead of a hashed next objective- Returns:
- int if found or -1 if there are errors in the creation of the neighbor set.
-
getVlanNextObjectiveId
public int getVlanNextObjectiveId(org.onlab.packet.VlanId vlanId)
Returns the next objective of type broadcast associated with the vlan, or -1 if no such objective exists. Note that this method does NOT create the next objective as a side-effect. It is expected that is objective is created at startup from network configuration. Typically this is used for L2 flooding within the subnet configured on the switch.- Parameters:
vlanId- vlan id- Returns:
- int if found or -1
-
getMacVlanNextObjectiveId
public int getMacVlanNextObjectiveId(org.onlab.packet.MacAddress macAddr, org.onlab.packet.VlanId vlanId, org.onosproject.net.PortNumber port, boolean createIfMissing)Returns the next objective of type simple associated with the mac/vlan on the device, given the treatment. Different treatments to the same mac/vlan result in different next objectives. If no such objective exists, this method creates one (if requested) and returns the id. Optionally metadata can be passed in for the creation of the objective. Typically this is used for L2 and L3 forwarding to compute nodes and containers/VMs on the compute nodes directly attached to the switch.- Parameters:
macAddr- the mac addr for the simple next objectivevlanId- the vlan for the simple next objectiveport- port with which to create the Next Obj.createIfMissing- true if a next object should be created if not found- Returns:
- int if found or created, -1 if there are errors during the creation of the next objective.
-
getPortNextObjectiveId
public int getPortNextObjectiveId(org.onosproject.net.PortNumber portNum, org.onosproject.net.flow.TrafficTreatment treatment, org.onosproject.net.flow.TrafficSelector meta, boolean createIfMissing)Returns the next objective of type simple associated with the port on the device, given the treatment. Different treatments to the same port result in different next objectives. If no such objective exists, this method creates one (if requested) and returns the id. Optionally metadata can be passed in for the creation of the objective. Typically this is used for L2 and L3 forwarding to compute nodes and containers/VMs on the compute nodes directly attached to the switch.- Parameters:
portNum- the port number for the simple next objectivetreatment- the actions to apply on the packets (should include outport)meta- optional metadata passed into the creation of the next objectivecreateIfMissing- true if a next object should be created if not found- Returns:
- int if found or created, -1 if there are errors during the creation of the next objective.
-
hasNextObjectiveId
public boolean hasNextObjectiveId(DestinationSet ns)
Checks if the next objective ID (group) for the neighbor set exists or not.- Parameters:
ns- neighbor set to check- Returns:
- true if it exists, false otherwise
-
addNeighborAtPort
protected void addNeighborAtPort(org.onosproject.net.DeviceId neighborId, org.onosproject.net.PortNumber portToNeighbor)
-
createGroupFromDestinationSet
public void createGroupFromDestinationSet(DestinationSet ds, Map<org.onosproject.net.DeviceId,Set<org.onosproject.net.DeviceId>> neighbors, org.onosproject.net.flow.TrafficSelector meta, boolean simple)
Creates a NextObjective for a hash group in this device from a given DestinationSet. If the parameter simple is true, a simple next objective is created instead.- Parameters:
ds- the DestinationSetneighbors- a map for each destination and its next-hopsmeta- metadata passed into the creation of a Next Objectivesimple- if true, a simple next objective will be created instead of a hashed next objective
-
createGroupsFromVlanConfig
public void createGroupsFromVlanConfig()
Creates broadcast groups for all ports in the same subnet for all configured subnets.
-
createBcastGroupFromVlan
public void createBcastGroupFromVlan(org.onlab.packet.VlanId vlanId, Collection<org.onosproject.net.PortNumber> ports)Creates a single broadcast group from a given vlan id and list of ports.- Parameters:
vlanId- vlan idports- list of ports in the subnet
-
removeBcastGroupFromVlan
public void removeBcastGroupFromVlan(org.onosproject.net.DeviceId deviceId, org.onosproject.net.PortNumber portNum, org.onlab.packet.VlanId vlanId, boolean popVlan)Removes a single broadcast group from a given vlan id. The group should be empty.- Parameters:
deviceId- device Id to remove the groupportNum- port number related to the groupvlanId- vlan id of the broadcast group to removepopVlan- true if the TrafficTreatment involves pop vlan tag action
-
createGroupFromMacVlan
public int createGroupFromMacVlan(org.onlab.packet.MacAddress macAddr, org.onlab.packet.VlanId vlanId, org.onosproject.net.flow.TrafficTreatment treatment, org.onosproject.net.flow.TrafficSelector meta)Create simple next objective for an indirect host mac/vlan. The treatments can include all outgoing actions that need to happen on the packet.- Parameters:
macAddr- the mac address of the hostvlanId- the vlan of the hosttreatment- the actions to apply on the packets (should include outport)meta- optional data to pass to the driver- Returns:
- next objective ID
-
createGroupFromPort
public void createGroupFromPort(org.onosproject.net.PortNumber portNum, org.onosproject.net.flow.TrafficTreatment treatment, org.onosproject.net.flow.TrafficSelector meta)Create simple next objective for a single port. The treatments can include all outgoing actions that need to happen on the packet.- Parameters:
portNum- the outgoing port on the devicetreatment- the actions to apply on the packets (should include outport)meta- optional data to pass to the driver
-
createPortNextObjective
public void createPortNextObjective(org.onosproject.net.DeviceId deviceId, org.onosproject.net.PortNumber portNum, org.onlab.packet.VlanId vlanId, boolean popVlan)Creates simple next objective for a single port.- Parameters:
deviceId- device id that has the port to deal withportNum- the outgoing port on the devicevlanId- vlan id associated with the portpopVlan- true if POP_VLAN action is applied on the packets, false otherwise
-
removePortNextObjective
public void removePortNextObjective(org.onosproject.net.DeviceId deviceId, org.onosproject.net.PortNumber portNum, org.onlab.packet.VlanId vlanId, boolean popVlan)Removes simple next objective for a single port.- Parameters:
deviceId- device id that has the port to deal withportNum- the outgoing port on the devicevlanId- vlan id associated with the portpopVlan- true if POP_VLAN action is applied on the packets, false otherwise
-
removeGroup
public boolean removeGroup(int objectiveId)
Removes groups for the next objective ID given.- Parameters:
objectiveId- next objective ID to remove- Returns:
- true if succeeds, false otherwise
-
removeGroupFromPort
public CompletableFuture<org.onosproject.net.flowobjective.Objective> removeGroupFromPort(org.onosproject.net.PortNumber portNum, org.onosproject.net.flow.TrafficTreatment treatment, org.onosproject.net.flow.TrafficSelector meta)
Remove simple next objective for a single port. The treatments can include all outgoing actions that need to happen on the packet.- Parameters:
portNum- the outgoing port on the devicetreatment- the actions applied on the packets (should include outport)meta- optional data to pass to the driver- Returns:
- a completable future that completes when the port has been removed
-
triggerBucketCorrector
public void triggerBucketCorrector()
Triggers a one time bucket verification operation on all hash groups on this device.
-
updateL2InterfaceGroupBucket
public void updateL2InterfaceGroupBucket(org.onosproject.net.PortNumber portNumber, org.onlab.packet.VlanId vlanId, boolean pushVlan)Modifies L2IG bucket when the interface configuration is updated, especially when the interface has same VLAN ID but the VLAN type is changed (e.g., from vlan-tagged [10] to vlan-untagged 10), which requires changes on TrafficTreatment in turn.- Parameters:
portNumber- the port on this device that needs to be updatedvlanId- the vlan id corresponding to this portpushVlan- indicates if packets should be sent out untagged or not out from the port. If true, updated TrafficTreatment involves pop vlan tag action. If false, updated TrafficTreatment does not involve pop vlan tag action.
-
updateL3UcastGroupBucket
public void updateL3UcastGroupBucket(org.onlab.packet.MacAddress hostMac, org.onlab.packet.VlanId hostVlanId, org.onosproject.net.PortNumber port, int nextId)Updates the next objective for the given nextId .- Parameters:
hostMac- mac of host for which Next obj is to be updated.hostVlanId- vlan of host for which Next obj is to be updated.port- port with which to update the Next Obj.nextId- of Next Obj which needs to be updated.
-
updateGroupFromVlanConfiguration
public void updateGroupFromVlanConfiguration(org.onlab.packet.VlanId vlanId, org.onosproject.net.PortNumber portNum, int nextId, boolean install)Adds a single port to the L2FG or removes it from the L2FG.- Parameters:
vlanId- the vlan id corresponding to this portportNum- the port on this device to be updatednextId- the next objective ID for the given vlan idinstall- if true, adds the port to L2FG. If false, removes it from L2FG.
-
-