Class 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 class  DefaultGroupHandler.BucketCorrector
      Performs bucket verification operation for all hash groups in this device.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      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 Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addNeighborAtPort​(org.onosproject.net.DeviceId neighborId, org.onosproject.net.PortNumber portToNeighbor)  
      void cleanUpForNeighborDown​(org.onosproject.net.DeviceId neighborId)
      Cleans up local stores for removed neighbor device.
      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.
      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.
      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.
      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.
      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)
      Creates a group handler object.
      void createGroupsFromVlanConfig()
      Creates broadcast groups for all ports in the same subnet for all configured subnets.
      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.
      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.
      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.
      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.
      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.
      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.
      boolean hasNextObjectiveId​(DestinationSet ns)
      Checks if the next objective ID (group) for the neighbor set exists or not.
      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.
      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.
      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.
      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.
      boolean removeGroup​(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.
      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.
      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.
      void shutdown()
      Gracefully shuts down a groupHandler.
      void triggerBucketCorrector()
      Triggers a one time bucket verification operation on all hash groups on this device.
      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.
      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.
      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 .
    • 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
      • allSegmentIds

        protected final List<Integer> allSegmentIds
      • 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.
      • 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 identifier
        appId - application identifier
        config - interface to retrieve the device properties
        linkService - link service object
        flowObjService - flow objective service object
        srManager - 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 up
        linkDown - true if link has gone down
        firstTime - 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 edited
        nextHops - the current next hops for the target switch to reach the dest sw
        destSw - the destination switch
        revoke - 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 group
        vlanId - the vlan id corresponding to the broadcast domain/group
        popVlan - 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 set
        nextHops - a map of per destination next hops
        meta - metadata passed into the creation of a Next Objective
        simple - 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 objective
        vlanId - the vlan for the simple next objective
        port - 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 objective
        treatment - the actions to apply on the packets (should include outport)
        meta - optional metadata passed into the creation of the next objective
        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.
      • 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 DestinationSet
        neighbors - a map for each destination and its next-hops
        meta - metadata passed into the creation of a Next Objective
        simple - 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 id
        ports - 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 group
        portNum - port number related to the group
        vlanId - vlan id of the broadcast group to remove
        popVlan - 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 host
        vlanId - the vlan of the host
        treatment - 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 device
        treatment - 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 with
        portNum - the outgoing port on the device
        vlanId - vlan id associated with the port
        popVlan - 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 with
        portNum - the outgoing port on the device
        vlanId - vlan id associated with the port
        popVlan - 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 device
        treatment - 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 updated
        vlanId - the vlan id corresponding to this port
        pushVlan - 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 port
        portNum - the port on this device to be updated
        nextId - the next objective ID for the given vlan id
        install - if true, adds the port to L2FG. If false, removes it from L2FG.