David K. Bainbridge | d77028f | 2017-08-01 12:47:55 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 4d08470 | 2017-08-03 22:45:58 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
David K. Bainbridge | d77028f | 2017-08-01 12:47:55 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
developer | e400c58 | 2020-03-24 19:42:08 +0100 | [diff] [blame] | 16 | package org.opencord.igmpproxy.impl; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 17 | |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 18 | import com.google.common.collect.Sets; |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 19 | import org.onosproject.net.Device; |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 20 | import org.opencord.igmpproxy.IgmpLeadershipService; |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 21 | import org.opencord.igmpproxy.IgmpStatisticType; |
developer | e400c58 | 2020-03-24 19:42:08 +0100 | [diff] [blame] | 22 | import org.opencord.igmpproxy.IgmpStatisticsService; |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 23 | import org.opencord.igmpproxy.impl.store.groupmember.GroupMember; |
| 24 | import org.opencord.igmpproxy.GroupMemberId; |
| 25 | import org.opencord.igmpproxy.impl.store.groupmember.GroupMemberStore; |
| 26 | import org.opencord.igmpproxy.statemachine.StateMachineService; |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 27 | import org.opencord.sadis.BaseInformationService; |
| 28 | import org.opencord.sadis.SadisService; |
| 29 | import org.opencord.sadis.SubscriberAndDeviceInformation; |
Carmelo Cascone | bef302e | 2019-11-14 19:58:20 -0800 | [diff] [blame] | 30 | import org.osgi.service.component.annotations.Activate; |
| 31 | import org.osgi.service.component.annotations.Component; |
| 32 | import org.osgi.service.component.annotations.Deactivate; |
| 33 | import org.osgi.service.component.annotations.Reference; |
| 34 | import org.osgi.service.component.annotations.ReferenceCardinality; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 35 | import org.onlab.packet.EthType; |
| 36 | import org.onlab.packet.Ethernet; |
| 37 | import org.onlab.packet.IGMP; |
| 38 | import org.onlab.packet.IGMPGroup; |
| 39 | import org.onlab.packet.IGMPMembership; |
| 40 | import org.onlab.packet.IGMPQuery; |
| 41 | import org.onlab.packet.IPv4; |
| 42 | import org.onlab.packet.Ip4Address; |
| 43 | import org.onlab.packet.IpAddress; |
| 44 | import org.onlab.packet.VlanId; |
| 45 | import org.onosproject.core.ApplicationId; |
| 46 | import org.onosproject.core.CoreService; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 47 | import org.onosproject.mastership.MastershipService; |
| 48 | import org.onosproject.net.AnnotationKeys; |
| 49 | import org.onosproject.net.ConnectPoint; |
| 50 | import org.onosproject.net.DeviceId; |
| 51 | import org.onosproject.net.Port; |
| 52 | import org.onosproject.net.PortNumber; |
| 53 | import org.onosproject.net.config.ConfigFactory; |
| 54 | import org.onosproject.net.config.NetworkConfigEvent; |
| 55 | import org.onosproject.net.config.NetworkConfigListener; |
| 56 | import org.onosproject.net.config.NetworkConfigRegistry; |
Jonathan Hart | 488e114 | 2018-05-02 17:30:05 -0700 | [diff] [blame] | 57 | import org.onosproject.net.config.basics.McastConfig; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 58 | import org.onosproject.net.config.basics.SubjectFactories; |
| 59 | import org.onosproject.net.device.DeviceEvent; |
| 60 | import org.onosproject.net.device.DeviceListener; |
| 61 | import org.onosproject.net.device.DeviceService; |
| 62 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 63 | import org.onosproject.net.flow.FlowRuleService; |
| 64 | import org.onosproject.net.flow.criteria.Criteria; |
| 65 | import org.onosproject.net.flowobjective.DefaultFilteringObjective; |
| 66 | import org.onosproject.net.flowobjective.FilteringObjective; |
| 67 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
| 68 | import org.onosproject.net.flowobjective.Objective; |
| 69 | import org.onosproject.net.flowobjective.ObjectiveContext; |
| 70 | import org.onosproject.net.flowobjective.ObjectiveError; |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 71 | import org.onosproject.mcast.api.McastRoute; |
| 72 | import org.onosproject.mcast.api.MulticastRouteService; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 73 | import org.onosproject.net.packet.InboundPacket; |
| 74 | import org.onosproject.net.packet.PacketContext; |
| 75 | import org.onosproject.net.packet.PacketProcessor; |
| 76 | import org.onosproject.net.packet.PacketService; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 77 | import org.slf4j.Logger; |
| 78 | import org.slf4j.LoggerFactory; |
| 79 | |
| 80 | import java.util.ArrayList; |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 81 | import java.util.Arrays; |
| 82 | import java.util.List; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 83 | import java.util.Collection; |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 84 | import java.util.HashSet; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 85 | import java.util.Iterator; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 86 | import java.util.Map; |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 87 | import java.util.Optional; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 88 | import java.util.Set; |
| 89 | import java.util.TimerTask; |
| 90 | import java.util.concurrent.ConcurrentHashMap; |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 91 | import java.util.concurrent.ExecutorService; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 92 | import java.util.concurrent.Executors; |
| 93 | import java.util.concurrent.ScheduledExecutorService; |
| 94 | import java.util.concurrent.TimeUnit; |
| 95 | |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 96 | import static org.onlab.packet.IGMPMembership.MODE_IS_INCLUDE; |
| 97 | import static org.onlab.packet.IGMPMembership.MODE_IS_EXCLUDE; |
| 98 | import static org.onlab.packet.IGMPMembership.CHANGE_TO_INCLUDE_MODE; |
| 99 | import static org.onlab.packet.IGMPMembership.CHANGE_TO_EXCLUDE_MODE; |
| 100 | import static org.onlab.packet.IGMPMembership.ALLOW_NEW_SOURCES; |
| 101 | import static org.onlab.packet.IGMPMembership.BLOCK_OLD_SOURCES; |
| 102 | |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 103 | import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; |
| 104 | import static org.onlab.util.Tools.groupedThreads; |
| 105 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 106 | /** |
| 107 | * Igmp process application, use proxy mode, support first join/ last leave , fast leave |
| 108 | * period query and keep alive, packet out igmp message to uplink port features. |
| 109 | */ |
| 110 | @Component(immediate = true) |
| 111 | public class IgmpManager { |
| 112 | |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 113 | private static final String APP_NAME = "org.opencord.igmpproxy"; |
| 114 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 115 | private static final Class<IgmpproxyConfig> IGMPPROXY_CONFIG_CLASS = |
| 116 | IgmpproxyConfig.class; |
| 117 | private static final Class<IgmpproxySsmTranslateConfig> IGMPPROXY_SSM_CONFIG_CLASS = |
| 118 | IgmpproxySsmTranslateConfig.class; |
| 119 | private static final Class<McastConfig> MCAST_CONFIG_CLASS = |
| 120 | McastConfig.class; |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 121 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 122 | private static ApplicationId appId; |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 123 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 124 | private static int unSolicitedTimeout = 3; // unit is 1 sec |
| 125 | private static int keepAliveCount = 3; |
| 126 | private static int lastQueryInterval = 2; //unit is 1 sec |
| 127 | private static int lastQueryCount = 2; |
| 128 | private static boolean fastLeave = true; |
| 129 | private static boolean withRAUplink = true; |
| 130 | private static boolean withRADownlink = false; |
| 131 | private static boolean periodicQuery = true; |
| 132 | private static short mvlan = 4000; |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame] | 133 | private static short mvlanInner = VlanId.NONE.toShort(); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 134 | private static byte igmpCos = 7; |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame] | 135 | private static byte igmpUniCos = 7; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 136 | public static boolean connectPointMode = true; |
| 137 | public static ConnectPoint connectPoint = null; |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 138 | private static ConnectPoint sourceDeviceAndPort = null; |
| 139 | private static boolean enableIgmpProvisioning = false; |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 140 | private static boolean igmpOnPodBasis = false; |
Arjun E K | b0018fd | 2020-04-07 13:26:40 +0000 | [diff] [blame] | 141 | private static boolean outgoingIgmpWithV3 = true; |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 142 | |
| 143 | private static final Integer MAX_PRIORITY = 10000; |
| 144 | private static final String INSTALLED = "installed"; |
| 145 | private static final String REMOVED = "removed"; |
| 146 | private static final String INSTALLATION = "installation"; |
| 147 | private static final String REMOVAL = "removal"; |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 148 | private static final String NNI_PREFIX = "nni"; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 149 | |
ke han | 29af27b | 2017-09-08 10:29:12 +0800 | [diff] [blame] | 150 | private static boolean pimSSmInterworking = false; |
| 151 | private static final String DEFAULT_PIMSSM_HOST = "127.0.0.1"; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 152 | private final ScheduledExecutorService scheduledExecutorService = |
| 153 | Executors.newScheduledThreadPool(1); |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 154 | |
Carmelo Cascone | bef302e | 2019-11-14 19:58:20 -0800 | [diff] [blame] | 155 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 156 | protected CoreService coreService; |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 157 | |
Carmelo Cascone | bef302e | 2019-11-14 19:58:20 -0800 | [diff] [blame] | 158 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 159 | protected PacketService packetService; |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 160 | |
Carmelo Cascone | bef302e | 2019-11-14 19:58:20 -0800 | [diff] [blame] | 161 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 162 | protected MastershipService mastershipService; |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 163 | |
Carmelo Cascone | bef302e | 2019-11-14 19:58:20 -0800 | [diff] [blame] | 164 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 165 | protected FlowRuleService flowRuleService; |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 166 | |
Carmelo Cascone | bef302e | 2019-11-14 19:58:20 -0800 | [diff] [blame] | 167 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 168 | protected DeviceService deviceService; |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 169 | |
Carmelo Cascone | bef302e | 2019-11-14 19:58:20 -0800 | [diff] [blame] | 170 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 171 | protected FlowObjectiveService flowObjectiveService; |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 172 | |
Carmelo Cascone | bef302e | 2019-11-14 19:58:20 -0800 | [diff] [blame] | 173 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 174 | protected NetworkConfigRegistry networkConfig; |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 175 | |
Carmelo Cascone | bef302e | 2019-11-14 19:58:20 -0800 | [diff] [blame] | 176 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 177 | protected MulticastRouteService multicastService; |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 178 | |
| 179 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
| 180 | protected SadisService sadisService; |
| 181 | |
Shubham Sharma | 47f2caf | 2020-02-18 12:13:40 +0000 | [diff] [blame] | 182 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
| 183 | protected IgmpStatisticsService igmpStatisticsManager; |
| 184 | |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 185 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
| 186 | protected GroupMemberStore groupMemberStore; |
| 187 | |
| 188 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
| 189 | protected StateMachineService stateMachineService; |
| 190 | |
| 191 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
| 192 | protected IgmpLeadershipService igmpLeadershipService; |
| 193 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 194 | private IgmpPacketProcessor processor = new IgmpPacketProcessor(); |
| 195 | private Logger log = LoggerFactory.getLogger(getClass()); |
| 196 | private ApplicationId coreAppId; |
| 197 | private Map<Ip4Address, Ip4Address> ssmTranslateTable = new ConcurrentHashMap<>(); |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 198 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 199 | private InternalNetworkConfigListener configListener = |
| 200 | new InternalNetworkConfigListener(); |
| 201 | private DeviceListener deviceListener = new InternalDeviceListener(); |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 202 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 203 | private ConfigFactory<ApplicationId, IgmpproxyConfig> igmpproxyConfigFactory = |
| 204 | new ConfigFactory<ApplicationId, IgmpproxyConfig>( |
| 205 | SubjectFactories.APP_SUBJECT_FACTORY, IGMPPROXY_CONFIG_CLASS, "igmpproxy") { |
| 206 | @Override |
| 207 | public IgmpproxyConfig createConfig() { |
| 208 | return new IgmpproxyConfig(); |
| 209 | } |
| 210 | }; |
| 211 | private ConfigFactory<ApplicationId, IgmpproxySsmTranslateConfig> igmpproxySsmConfigFactory = |
| 212 | new ConfigFactory<ApplicationId, IgmpproxySsmTranslateConfig>( |
| 213 | SubjectFactories.APP_SUBJECT_FACTORY, IGMPPROXY_SSM_CONFIG_CLASS, "ssmTranslate", true) { |
| 214 | @Override |
| 215 | public IgmpproxySsmTranslateConfig createConfig() { |
| 216 | return new IgmpproxySsmTranslateConfig(); |
| 217 | } |
| 218 | }; |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 219 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 220 | private int maxResp = 10; //unit is 1 sec |
| 221 | private int keepAliveInterval = 120; //unit is 1 sec |
| 222 | |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 223 | private ExecutorService eventExecutor; |
| 224 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 225 | public static int getUnsolicitedTimeout() { |
| 226 | return unSolicitedTimeout; |
| 227 | } |
| 228 | |
Arjun E K | b0018fd | 2020-04-07 13:26:40 +0000 | [diff] [blame] | 229 | public static boolean outgoingIgmpWithV3() { |
| 230 | return outgoingIgmpWithV3; |
| 231 | } |
| 232 | |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 233 | protected BaseInformationService<SubscriberAndDeviceInformation> subsService; |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 234 | |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 235 | private List<Byte> validMembershipModes = Arrays.asList(MODE_IS_INCLUDE, MODE_IS_EXCLUDE, CHANGE_TO_INCLUDE_MODE, |
| 236 | CHANGE_TO_EXCLUDE_MODE, ALLOW_NEW_SOURCES, BLOCK_OLD_SOURCES); |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 237 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 238 | @Activate |
| 239 | protected void activate() { |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 240 | appId = coreService.registerApplication(APP_NAME); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 241 | coreAppId = coreService.registerApplication(CoreService.CORE_APP_NAME); |
| 242 | packetService.addProcessor(processor, PacketProcessor.director(4)); |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 243 | IgmpSender.init(packetService, igmpLeadershipService, igmpStatisticsManager); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 244 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 245 | networkConfig.registerConfigFactory(igmpproxySsmConfigFactory); |
| 246 | networkConfig.registerConfigFactory(igmpproxyConfigFactory); |
| 247 | networkConfig.addListener(configListener); |
| 248 | |
| 249 | configListener.reconfigureNetwork(networkConfig.getConfig(appId, IGMPPROXY_CONFIG_CLASS)); |
| 250 | configListener.reconfigureSsmTable(networkConfig.getConfig(appId, IGMPPROXY_SSM_CONFIG_CLASS)); |
| 251 | |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 252 | subsService = sadisService.getSubscriberInfoService(); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 253 | if (connectPointMode) { |
| 254 | provisionConnectPointFlows(); |
| 255 | } else { |
| 256 | provisionUplinkFlows(); |
| 257 | } |
| 258 | |
| 259 | McastConfig config = networkConfig.getConfig(coreAppId, MCAST_CONFIG_CLASS); |
| 260 | if (config != null) { |
| 261 | mvlan = config.egressVlan().toShort(); |
Deepa Vaddireddy | 88134a4 | 2017-07-05 12:16:03 +0530 | [diff] [blame] | 262 | IgmpSender.getInstance().setMvlan(mvlan); |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame] | 263 | mvlanInner = config.egressInnerVlan().toShort(); |
| 264 | IgmpSender.getInstance().setMvlanInner(mvlanInner); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 265 | } |
| 266 | deviceService.addListener(deviceListener); |
Sonal Kasliwal | ddc3ff2 | 2019-11-18 11:52:49 +0000 | [diff] [blame] | 267 | scheduledExecutorService.scheduleAtFixedRate(new IgmpProxyTimerTask(), 1000, 1000, TimeUnit.MILLISECONDS); |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 268 | eventExecutor = newSingleThreadScheduledExecutor(groupedThreads("cord/igmpproxy", |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 269 | "events-igmp-%d", log)); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 270 | log.info("Started"); |
| 271 | } |
| 272 | |
| 273 | @Deactivate |
| 274 | protected void deactivate() { |
| 275 | scheduledExecutorService.shutdown(); |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 276 | eventExecutor.shutdown(); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 277 | |
| 278 | // de-register and null our handler |
| 279 | networkConfig.removeListener(configListener); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 280 | networkConfig.unregisterConfigFactory(igmpproxyConfigFactory); |
| 281 | networkConfig.unregisterConfigFactory(igmpproxySsmConfigFactory); |
| 282 | deviceService.removeListener(deviceListener); |
| 283 | packetService.removeProcessor(processor); |
| 284 | flowRuleService.removeFlowRulesById(appId); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 285 | log.info("Stopped"); |
| 286 | } |
| 287 | |
| 288 | protected Ip4Address getDeviceIp(DeviceId ofDeviceId) { |
| 289 | try { |
| 290 | String[] mgmtAddress = deviceService.getDevice(ofDeviceId) |
| 291 | .annotations().value(AnnotationKeys.MANAGEMENT_ADDRESS).split(":"); |
| 292 | return Ip4Address.valueOf(mgmtAddress[0]); |
| 293 | } catch (Exception ex) { |
| 294 | log.info("No valid Ipaddress for " + ofDeviceId.toString()); |
| 295 | return null; |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | private void processIgmpQuery(IGMPQuery igmpQuery, ConnectPoint cp, int maxResp) { |
| 300 | |
| 301 | DeviceId deviceId = cp.deviceId(); |
| 302 | Ip4Address gAddr = igmpQuery.getGaddr().getIp4Address(); |
Deepa Vaddireddy | bcd5235 | 2017-09-21 05:04:48 +0000 | [diff] [blame] | 303 | maxResp = calculateMaxResp(maxResp); |
| 304 | if (gAddr != null && !gAddr.isZero()) { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 305 | stateMachineService.specialQuery(deviceId, gAddr, maxResp); |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 306 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_GRP_SPECIFIC_MEMBERSHIP_QUERY); |
Deepa Vaddireddy | bcd5235 | 2017-09-21 05:04:48 +0000 | [diff] [blame] | 307 | } else { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 308 | stateMachineService.generalQuery(deviceId, maxResp); |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 309 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_GENERAL_MEMBERSHIP_QUERY); |
Deepa Vaddireddy | bcd5235 | 2017-09-21 05:04:48 +0000 | [diff] [blame] | 310 | } |
| 311 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 312 | |
Deepa Vaddireddy | bcd5235 | 2017-09-21 05:04:48 +0000 | [diff] [blame] | 313 | private void processIgmpConnectPointQuery(IGMPQuery igmpQuery, ConnectPoint cp, int maxResp) { |
| 314 | |
Deepa Vaddireddy | bcd5235 | 2017-09-21 05:04:48 +0000 | [diff] [blame] | 315 | Ip4Address gAddr = igmpQuery.getGaddr().getIp4Address(); |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 316 | final int maxResponseTime = calculateMaxResp(maxResp); |
Deepa Vaddireddy | bcd5235 | 2017-09-21 05:04:48 +0000 | [diff] [blame] | 317 | //The query is received on the ConnectPoint |
| 318 | // send query accordingly to the registered OLT devices. |
| 319 | if (gAddr != null && !gAddr.isZero()) { |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 320 | deviceService.getAvailableDevices().forEach(device -> { |
| 321 | Optional<SubscriberAndDeviceInformation> accessDevice = getSubscriberAndDeviceInformation(device.id()); |
| 322 | if (accessDevice.isPresent()) { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 323 | stateMachineService.specialQuery(device.id(), gAddr, maxResponseTime); |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 324 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_GRP_AND_SRC_SPESIFIC_MEMBERSHIP_QUERY); |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 325 | } |
| 326 | }); |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 327 | igmpStatisticsManager.increaseStat(IgmpStatisticType.CURRENT_GRP_NUMBER_COUNTER); |
Deepa Vaddireddy | bcd5235 | 2017-09-21 05:04:48 +0000 | [diff] [blame] | 328 | } else { |
| 329 | //Don't know which group is targeted by the query |
| 330 | //So query all the members(in all the OLTs) and proxy their reports |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 331 | stateMachineService.generalQuery(maxResponseTime); |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 332 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_GENERAL_MEMBERSHIP_QUERY); |
Deepa Vaddireddy | bcd5235 | 2017-09-21 05:04:48 +0000 | [diff] [blame] | 333 | } |
| 334 | } |
| 335 | |
| 336 | |
| 337 | private int calculateMaxResp(int maxResp) { |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 338 | if (maxResp >= 128) { |
| 339 | int mant = maxResp & 0xf; |
| 340 | int exp = (maxResp >> 4) & 0x7; |
| 341 | maxResp = (mant | 0x10) << (exp + 3); |
| 342 | } |
| 343 | |
Deepa Vaddireddy | bcd5235 | 2017-09-21 05:04:48 +0000 | [diff] [blame] | 344 | return (maxResp + 5) / 10; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | private Ip4Address ssmTranslateRoute(IpAddress group) { |
| 348 | return ssmTranslateTable.get(group); |
| 349 | } |
| 350 | |
| 351 | private void processIgmpReport(IGMPMembership igmpGroup, VlanId vlan, ConnectPoint cp, byte igmpType) { |
| 352 | DeviceId deviceId = cp.deviceId(); |
| 353 | PortNumber portNumber = cp.port(); |
| 354 | |
Andrea Campanella | 2c70a57 | 2020-06-05 13:31:45 +0200 | [diff] [blame^] | 355 | log.debug("Processing IGMP report on membership {} for vlan {} on port {} with type {}", |
| 356 | igmpGroup, vlan, cp, igmpType); |
| 357 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 358 | Ip4Address groupIp = igmpGroup.getGaddr().getIp4Address(); |
| 359 | if (!groupIp.isMulticast()) { |
| 360 | log.info(groupIp.toString() + " is not a valid group address"); |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 361 | igmpStatisticsManager.increaseStat(IgmpStatisticType.FAIL_JOIN_REQ_UNKNOWN_MULTICAST_IP_COUNTER); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 362 | return; |
| 363 | } |
| 364 | Ip4Address srcIp = getDeviceIp(deviceId); |
| 365 | |
| 366 | byte recordType = igmpGroup.getRecordType(); |
| 367 | boolean join = false; |
| 368 | |
| 369 | ArrayList<Ip4Address> sourceList = new ArrayList<>(); |
| 370 | |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 371 | if (!validMembershipModes.contains(recordType)) { |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 372 | igmpStatisticsManager.increaseStat(IgmpStatisticType.REPORTS_RX_WITH_WRONG_MODE_COUNTER); |
Sonal Kasliwal | f11c067 | 2020-03-18 11:11:50 +0000 | [diff] [blame] | 373 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 374 | if (igmpGroup.getSources().size() > 0) { |
| 375 | igmpGroup.getSources().forEach(source -> sourceList.add(source.getIp4Address())); |
| 376 | if (recordType == IGMPMembership.CHANGE_TO_EXCLUDE_MODE || |
| 377 | recordType == IGMPMembership.MODE_IS_EXCLUDE || |
| 378 | recordType == IGMPMembership.BLOCK_OLD_SOURCES) { |
| 379 | join = false; |
| 380 | } else if (recordType == IGMPMembership.CHANGE_TO_INCLUDE_MODE || |
| 381 | recordType == IGMPMembership.MODE_IS_INCLUDE || |
| 382 | recordType == IGMPMembership.ALLOW_NEW_SOURCES) { |
| 383 | join = true; |
| 384 | } |
| 385 | } else { |
ke han | 29af27b | 2017-09-08 10:29:12 +0800 | [diff] [blame] | 386 | IpAddress src = null; |
| 387 | if (pimSSmInterworking) { |
| 388 | src = ssmTranslateRoute(groupIp); |
| 389 | if (src == null) { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 390 | log.info("no ssm translate for group {}", groupIp); |
ke han | 29af27b | 2017-09-08 10:29:12 +0800 | [diff] [blame] | 391 | return; |
| 392 | } |
| 393 | } else { |
| 394 | src = IpAddress.valueOf(DEFAULT_PIMSSM_HOST); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 395 | } |
| 396 | sourceList.add(src.getIp4Address()); |
| 397 | if (recordType == IGMPMembership.CHANGE_TO_EXCLUDE_MODE || |
| 398 | recordType == IGMPMembership.MODE_IS_EXCLUDE || |
| 399 | recordType == IGMPMembership.BLOCK_OLD_SOURCES) { |
| 400 | join = true; |
| 401 | } else if (recordType == IGMPMembership.CHANGE_TO_INCLUDE_MODE || |
| 402 | recordType == IGMPMembership.MODE_IS_INCLUDE || |
| 403 | recordType == IGMPMembership.ALLOW_NEW_SOURCES) { |
| 404 | join = false; |
| 405 | } |
| 406 | } |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 407 | GroupMemberId groupMemberKey = GroupMemberId.of(groupIp, deviceId, portNumber); |
| 408 | GroupMember groupMember = groupMemberStore.getGroupMember(groupMemberKey); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 409 | |
| 410 | if (join) { |
Andrea Campanella | 2c70a57 | 2020-06-05 13:31:45 +0200 | [diff] [blame^] | 411 | log.debug("Received join on {} for vlan {}", cp, vlan); |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 412 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_JOIN_REQ); |
Andrea Campanella | 2c70a57 | 2020-06-05 13:31:45 +0200 | [diff] [blame^] | 413 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 414 | if (groupMember == null) { |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 415 | Optional<ConnectPoint> sourceConfigured = getSource(); |
| 416 | if (!sourceConfigured.isPresent()) { |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 417 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_FAIL_JOIN_REQ); |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 418 | log.warn("Unable to process IGMP Join from {} since no source " + |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 419 | "configuration is found.", deviceId); |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 420 | igmpStatisticsManager |
| 421 | .increaseStat(IgmpStatisticType.FAIL_JOIN_REQ_INSUFF_PERMISSION_ACCESS_COUNTER); |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 422 | return; |
| 423 | } |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 424 | |
| 425 | Optional<PortNumber> deviceUplink = getDeviceUplink(deviceId); |
| 426 | if (deviceUplink.isEmpty()) { |
| 427 | log.warn("Unable to process IGMP Join since uplink port " + |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 428 | "of the device {} is not found.", deviceId); |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 429 | return; |
| 430 | } |
| 431 | |
| 432 | if (igmpType == IGMP.TYPE_IGMPV2_MEMBERSHIP_REPORT) { |
| 433 | groupMember = new GroupMember(groupIp, vlan, deviceId, portNumber, true); |
| 434 | } else { |
| 435 | groupMember = new GroupMember(groupIp, vlan, deviceId, portNumber, false); |
| 436 | } |
| 437 | |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 438 | HashSet<ConnectPoint> sourceConnectPoints = Sets.newHashSet(sourceConfigured.get()); |
| 439 | |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 440 | boolean isJoined = stateMachineService.join(deviceId, groupIp, srcIp, deviceUplink.get()); |
Shubham Sharma | 47f2caf | 2020-02-18 12:13:40 +0000 | [diff] [blame] | 441 | if (isJoined) { |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 442 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_SUCCESS_JOIN_RE_JOIN_REQ); |
| 443 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_CHANNEL_JOIN_COUNTER); |
Shubham Sharma | 47f2caf | 2020-02-18 12:13:40 +0000 | [diff] [blame] | 444 | } else { |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 445 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_FAIL_JOIN_REQ); |
Shubham Sharma | 47f2caf | 2020-02-18 12:13:40 +0000 | [diff] [blame] | 446 | } |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 447 | groupMemberStore.putGroupMember(groupMember); |
| 448 | log.debug("Group member created with id: {}", groupMember.getGroupMemberId()); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 449 | groupMember.updateList(recordType, sourceList); |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 450 | groupMember.getSourceList().forEach(source -> { |
| 451 | McastRoute route = new McastRoute(source, groupIp, McastRoute.Type.IGMP); |
| 452 | //add route |
| 453 | multicastService.add(route); |
| 454 | //add source to the route |
| 455 | multicastService.addSources(route, Sets.newHashSet(sourceConnectPoints)); |
| 456 | //add sink to the route |
| 457 | multicastService.addSinks(route, Sets.newHashSet(cp)); |
| 458 | }); |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 459 | igmpStatisticsManager.increaseStat(IgmpStatisticType.UNCONFIGURED_GROUP_COUNTER); |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 460 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 461 | } |
| 462 | groupMember.resetAllTimers(); |
| 463 | groupMember.updateList(recordType, sourceList); |
| 464 | groupMember.setLeave(false); |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 465 | //put updated member to the store |
| 466 | groupMemberStore.putGroupMember(groupMember); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 467 | } else { |
Andrea Campanella | 2c70a57 | 2020-06-05 13:31:45 +0200 | [diff] [blame^] | 468 | log.debug("Received leave on {} for vlan {}", cp, vlan); |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 469 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_LEAVE_REQ); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 470 | if (groupMember == null) { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 471 | log.info("receive leave but no instance, group {} device: {} port:{}", |
| 472 | groupIp, deviceId, portNumber); |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 473 | igmpStatisticsManager.increaseStat(IgmpStatisticType.UNCONFIGURED_GROUP_COUNTER); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 474 | return; |
| 475 | } else { |
| 476 | groupMember.setLeave(true); |
| 477 | if (fastLeave) { |
| 478 | leaveAction(groupMember); |
| 479 | } else { |
| 480 | sendQuery(groupMember); |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 481 | //put modified group member object to the store |
| 482 | groupMemberStore.updateGroupMember(groupMember); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 483 | } |
| 484 | } |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | private void leaveAction(GroupMember groupMember) { |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 489 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_DISCONNECT); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 490 | ConnectPoint cp = new ConnectPoint(groupMember.getDeviceId(), groupMember.getPortNumber()); |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 491 | stateMachineService.leave(groupMember.getDeviceId(), groupMember.getGroupIp()); |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 492 | groupMember.getSourceList().forEach(source -> multicastService.removeSinks( |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 493 | new McastRoute(source, groupMember.getGroupIp(), |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 494 | McastRoute.Type.IGMP), Sets.newHashSet(cp))); |
| 495 | groupMemberStore.removeGroupMember(groupMember.getGroupMemberId()); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | private void sendQuery(GroupMember groupMember) { |
| 499 | Ethernet ethpkt; |
| 500 | Ip4Address srcIp = getDeviceIp(groupMember.getDeviceId()); |
| 501 | if (groupMember.getv2()) { |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame] | 502 | ethpkt = IgmpSender.getInstance().buildIgmpV2Query(groupMember.getGroupIp(), |
| 503 | srcIp, groupMember.getvlan().toShort()); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 504 | } else { |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame] | 505 | ethpkt = IgmpSender.getInstance().buildIgmpV3Query(groupMember.getGroupIp(), |
| 506 | srcIp, groupMember.getvlan().toShort()); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 507 | } |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame] | 508 | log.debug("Sending IGMP query to {}/{} for group {}: {}", |
| 509 | groupMember.getDeviceId(), groupMember.getPortNumber(), groupMember.getGroupIp(), ethpkt); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 510 | IgmpSender.getInstance().sendIgmpPacket(ethpkt, groupMember.getDeviceId(), groupMember.getPortNumber()); |
| 511 | } |
| 512 | |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 513 | /** |
| 514 | * @return connect point of the source if configured; and empty Optional otherwise. |
| 515 | */ |
| 516 | public static Optional<ConnectPoint> getSource() { |
| 517 | return sourceDeviceAndPort == null ? Optional.empty() : |
| 518 | Optional.of(sourceDeviceAndPort); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | /** |
| 522 | * Packet processor responsible for forwarding packets along their paths. |
| 523 | */ |
| 524 | private class IgmpPacketProcessor implements PacketProcessor { |
| 525 | @Override |
| 526 | public void process(PacketContext context) { |
Shubham Sharma | 47f2caf | 2020-02-18 12:13:40 +0000 | [diff] [blame] | 527 | |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 528 | eventExecutor.execute(() -> { |
| 529 | try { |
| 530 | InboundPacket pkt = context.inPacket(); |
| 531 | Ethernet ethPkt = pkt.parsed(); |
| 532 | if (ethPkt == null) { |
| 533 | return; |
| 534 | } |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 535 | igmpStatisticsManager.increaseStat(IgmpStatisticType.TOTAL_MSG_RECEIVED); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 536 | |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 537 | if (ethPkt.getEtherType() != Ethernet.TYPE_IPV4) { |
| 538 | return; |
| 539 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 540 | |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 541 | IPv4 ipv4Pkt = (IPv4) ethPkt.getPayload(); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 542 | |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 543 | if (ipv4Pkt.getProtocol() != IPv4.PROTOCOL_IGMP) { |
| 544 | return; |
| 545 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 546 | |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 547 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_VALID_CHECKSUM_COUNTER); |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 548 | short vlan = ethPkt.getVlanID(); |
| 549 | DeviceId deviceId = pkt.receivedFrom().deviceId(); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 550 | |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 551 | if (!isConnectPoint(deviceId, pkt.receivedFrom().port()) && |
| 552 | !getSubscriberAndDeviceInformation(deviceId).isPresent()) { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 553 | log.error("Device not registered in netcfg : {}", deviceId); |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 554 | igmpStatisticsManager |
| 555 | .increaseStat(IgmpStatisticType.FAIL_JOIN_REQ_INSUFF_PERMISSION_ACCESS_COUNTER); |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 556 | return; |
| 557 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 558 | |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 559 | IGMP igmp = (IGMP) ipv4Pkt.getPayload(); |
Esin Karaman | ce5ce51 | 2020-02-25 15:58:14 +0000 | [diff] [blame] | 560 | |
| 561 | Optional<PortNumber> deviceUpLinkOpt = getDeviceUplink(deviceId); |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 562 | PortNumber upLinkPort = deviceUpLinkOpt.isPresent() ? deviceUpLinkOpt.get() : null; |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 563 | switch (igmp.getIgmpType()) { |
| 564 | case IGMP.TYPE_IGMPV3_MEMBERSHIP_QUERY: |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 565 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_V3_MEMBERSHIP_QUERY); |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 566 | //Discard Query from OLT’s non-uplink port’s |
Esin Karaman | ce5ce51 | 2020-02-25 15:58:14 +0000 | [diff] [blame] | 567 | if (!pkt.receivedFrom().port().equals(upLinkPort)) { |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 568 | if (isConnectPoint(deviceId, pkt.receivedFrom().port())) { |
| 569 | log.info("IGMP Picked up query from connectPoint"); |
| 570 | //OK to process packet |
| 571 | processIgmpConnectPointQuery((IGMPQuery) igmp.getGroups().get(0), |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 572 | pkt.receivedFrom(), |
| 573 | 0xff & igmp.getMaxRespField()); |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 574 | break; |
| 575 | } else { |
| 576 | //Not OK to process packet |
Esin Karaman | ce5ce51 | 2020-02-25 15:58:14 +0000 | [diff] [blame] | 577 | log.warn("IGMP Picked up query from non-uplink port {}", upLinkPort); |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 578 | return; |
| 579 | } |
| 580 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 581 | |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 582 | processIgmpQuery((IGMPQuery) igmp.getGroups().get(0), pkt.receivedFrom(), |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 583 | 0xff & igmp.getMaxRespField()); |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 584 | break; |
| 585 | case IGMP.TYPE_IGMPV1_MEMBERSHIP_REPORT: |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 586 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_V1_MEMBERSHIP_REPORT); |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 587 | log.debug("IGMP version 1 message types are not currently supported."); |
| 588 | break; |
| 589 | case IGMP.TYPE_IGMPV3_MEMBERSHIP_REPORT: |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 590 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_V3_MEMBERSHIP_REPORT); |
Shubham Sharma | 47f2caf | 2020-02-18 12:13:40 +0000 | [diff] [blame] | 591 | processIgmpMessage(pkt, igmp, upLinkPort, vlan); |
| 592 | break; |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 593 | case IGMP.TYPE_IGMPV2_MEMBERSHIP_REPORT: |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 594 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_V2_MEMBERSHIP_REPORT); |
Shubham Sharma | 47f2caf | 2020-02-18 12:13:40 +0000 | [diff] [blame] | 595 | processIgmpMessage(pkt, igmp, upLinkPort, vlan); |
| 596 | break; |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 597 | case IGMP.TYPE_IGMPV2_LEAVE_GROUP: |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 598 | igmpStatisticsManager.increaseStat(IgmpStatisticType.IGMP_V2_LEAVE_GROUP); |
Shubham Sharma | 47f2caf | 2020-02-18 12:13:40 +0000 | [diff] [blame] | 599 | processIgmpMessage(pkt, igmp, upLinkPort, vlan); |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 600 | break; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 601 | |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 602 | default: |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 603 | log.warn("Unknown IGMP message type: {}", igmp.getIgmpType()); |
Ilayda Ozdemir | 0872abd | 2020-06-03 20:20:20 +0300 | [diff] [blame] | 604 | igmpStatisticsManager.increaseStat(IgmpStatisticType.INVALID_IGMP_MSG_RECEIVED); |
| 605 | igmpStatisticsManager.increaseStat(IgmpStatisticType.UNKNOWN_IGMP_TYPE_PACKETS_RX_COUNTER); |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 606 | break; |
| 607 | } |
| 608 | |
| 609 | } catch (Exception ex) { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 610 | log.error("igmp process error : ", ex); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 611 | } |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 612 | }); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 613 | } |
| 614 | } |
| 615 | |
Shubham Sharma | 47f2caf | 2020-02-18 12:13:40 +0000 | [diff] [blame] | 616 | private void processIgmpMessage(InboundPacket pkt, IGMP igmp, PortNumber upLinkPort, short vlan) { |
| 617 | //Discard join/leave from OLT’s uplink port’s |
| 618 | if (pkt.receivedFrom().port().equals(upLinkPort) || |
| 619 | isConnectPoint(pkt.receivedFrom().deviceId(), pkt.receivedFrom().port())) { |
| 620 | log.info("IGMP Picked up join/leave from uplink/connectPoint port"); |
| 621 | return; |
| 622 | } |
| 623 | |
| 624 | Iterator<IGMPGroup> itr = igmp.getGroups().iterator(); |
| 625 | while (itr.hasNext()) { |
| 626 | IGMPGroup group = itr.next(); |
| 627 | if (group instanceof IGMPMembership) { |
| 628 | processIgmpReport((IGMPMembership) group, VlanId.vlanId(vlan), |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 629 | pkt.receivedFrom(), igmp.getIgmpType()); |
Shubham Sharma | 47f2caf | 2020-02-18 12:13:40 +0000 | [diff] [blame] | 630 | } else { |
| 631 | IGMPMembership mgroup = new IGMPMembership(group.getGaddr().getIp4Address()); |
| 632 | mgroup.setRecordType(igmp.getIgmpType() == IGMP.TYPE_IGMPV2_MEMBERSHIP_REPORT ? |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 633 | IGMPMembership.MODE_IS_EXCLUDE : |
| 634 | IGMPMembership.MODE_IS_INCLUDE); |
Shubham Sharma | 47f2caf | 2020-02-18 12:13:40 +0000 | [diff] [blame] | 635 | processIgmpReport(mgroup, VlanId.vlanId(vlan), |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 636 | pkt.receivedFrom(), igmp.getIgmpType()); |
Shubham Sharma | 47f2caf | 2020-02-18 12:13:40 +0000 | [diff] [blame] | 637 | } |
| 638 | } |
| 639 | |
| 640 | } |
| 641 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 642 | private class IgmpProxyTimerTask extends TimerTask { |
| 643 | public void run() { |
| 644 | try { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 645 | stateMachineService.timeOut1s(); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 646 | queryMembers(); |
| 647 | } catch (Exception ex) { |
| 648 | log.warn("Igmp timer task error : {}", ex.getMessage()); |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | private void queryMembers() { |
| 653 | GroupMember groupMember; |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 654 | Set<GroupMemberId> keySet = groupMemberStore.getAllGroupMemberIds(); |
| 655 | for (GroupMemberId key : keySet) { |
| 656 | groupMember = groupMemberStore.getGroupMember(key); |
| 657 | if (groupMember == null) { |
| 658 | continue; |
| 659 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 660 | DeviceId did = groupMember.getDeviceId(); |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 661 | if (igmpLeadershipService.isLocalLeader(did)) { |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 662 | if (groupMember.isLeave()) { |
| 663 | lastQuery(groupMember); |
| 664 | } else if (periodicQuery) { |
| 665 | periodicQuery(groupMember); |
| 666 | } |
| 667 | } |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | private void lastQuery(GroupMember groupMember) { |
| 672 | if (groupMember.getLastQueryInterval() < lastQueryInterval) { |
| 673 | groupMember.lastQueryInterval(true); // count times |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 674 | //put modified group member object to the store |
| 675 | groupMemberStore.updateGroupMember(groupMember); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 676 | } else if (groupMember.getLastQueryCount() < lastQueryCount - 1) { |
| 677 | sendQuery(groupMember); |
| 678 | groupMember.lastQueryInterval(false); // reset count number |
| 679 | groupMember.lastQueryCount(true); //count times |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 680 | //put modified group member object to the store |
| 681 | groupMemberStore.updateGroupMember(groupMember); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 682 | } else if (groupMember.getLastQueryCount() == lastQueryCount - 1) { |
| 683 | leaveAction(groupMember); |
| 684 | } |
| 685 | } |
| 686 | |
| 687 | private void periodicQuery(GroupMember groupMember) { |
| 688 | if (groupMember.getKeepAliveQueryInterval() < keepAliveInterval) { |
| 689 | groupMember.keepAliveInterval(true); |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 690 | //put modified group member object to the store |
| 691 | groupMemberStore.updateGroupMember(groupMember); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 692 | } else if (groupMember.getKeepAliveQueryCount() < keepAliveCount) { |
| 693 | sendQuery(groupMember); |
| 694 | groupMember.keepAliveInterval(false); |
| 695 | groupMember.keepAliveQueryCount(true); |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 696 | //put modified group member object to the store |
| 697 | groupMemberStore.updateGroupMember(groupMember); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 698 | } else if (groupMember.getKeepAliveQueryCount() == keepAliveCount) { |
| 699 | leaveAction(groupMember); |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | } |
| 704 | |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 705 | public Optional<PortNumber> getDeviceUplink(DeviceId devId) { |
| 706 | Device device = deviceService.getDevice(devId); |
| 707 | if (device == null || device.serialNumber() == null) { |
| 708 | return Optional.empty(); |
Deepa Vaddireddy | bcd5235 | 2017-09-21 05:04:48 +0000 | [diff] [blame] | 709 | } |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 710 | Optional<SubscriberAndDeviceInformation> olt = getSubscriberAndDeviceInformation(device.serialNumber()); |
| 711 | if (olt.isEmpty()) { |
| 712 | return Optional.empty(); |
| 713 | } |
| 714 | PortNumber portNumber = PortNumber.portNumber(olt.get().uplinkPort()); |
| 715 | return validateUpLinkPort(device.id(), portNumber) ? |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 716 | Optional.of(portNumber) : Optional.empty(); |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | /** |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 720 | * @param deviceId device id |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 721 | * @param portNumber port number |
| 722 | * @return true if the port name starts with NNI_PREFIX; false otherwise. |
| 723 | */ |
| 724 | public boolean validateUpLinkPort(DeviceId deviceId, PortNumber portNumber) { |
| 725 | Port port = deviceService.getPort(deviceId, portNumber); |
| 726 | if (port == null) { |
| 727 | //port is not discovered by ONOS; so cannot validate it. |
| 728 | return false; |
| 729 | } |
Esin Karaman | ce5ce51 | 2020-02-25 15:58:14 +0000 | [diff] [blame] | 730 | boolean isValid = port.annotations().value(AnnotationKeys.PORT_NAME) != null && |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 731 | port.annotations().value(AnnotationKeys.PORT_NAME).startsWith(NNI_PREFIX); |
Esin Karaman | ce5ce51 | 2020-02-25 15:58:14 +0000 | [diff] [blame] | 732 | if (!isValid) { |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 733 | log.warn("Port cannot be validated; it is not configured as an NNI port. Device/port: {}/{}", |
| 734 | deviceId, portNumber); |
Esin Karaman | ce5ce51 | 2020-02-25 15:58:14 +0000 | [diff] [blame] | 735 | } |
| 736 | return isValid; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 737 | } |
| 738 | |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 739 | public static boolean isIgmpOnPodBasis() { |
| 740 | return igmpOnPodBasis; |
| 741 | } |
| 742 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 743 | private void processFilterObjective(DeviceId devId, PortNumber port, boolean remove) { |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 744 | if (!enableIgmpProvisioning) { |
| 745 | log.debug("IGMP trap rules won't be installed since enableIgmpProvisioning flag is not set"); |
| 746 | return; |
| 747 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 748 | //TODO migrate to packet requests when packet service uses filtering objectives |
| 749 | DefaultFilteringObjective.Builder builder = DefaultFilteringObjective.builder(); |
| 750 | |
| 751 | builder = remove ? builder.deny() : builder.permit(); |
| 752 | |
| 753 | FilteringObjective igmp = builder |
| 754 | .withKey(Criteria.matchInPort(port)) |
| 755 | .addCondition(Criteria.matchEthType(EthType.EtherType.IPV4.ethType())) |
| 756 | .addCondition(Criteria.matchIPProtocol(IPv4.PROTOCOL_IGMP)) |
| 757 | .withMeta(DefaultTrafficTreatment.builder().setOutput(PortNumber.CONTROLLER).build()) |
| 758 | .fromApp(appId) |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 759 | .withPriority(MAX_PRIORITY) |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 760 | .add(new ObjectiveContext() { |
| 761 | @Override |
| 762 | public void onSuccess(Objective objective) { |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 763 | log.info("Igmp filter for {} on {} {}.", |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 764 | devId, port, (remove) ? REMOVED : INSTALLED); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | @Override |
| 768 | public void onError(Objective objective, ObjectiveError error) { |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 769 | log.info("Igmp filter {} for device {} on port {} failed because of {}", |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 770 | (remove) ? INSTALLATION : REMOVAL, devId, port, |
| 771 | error); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 772 | } |
| 773 | }); |
| 774 | |
| 775 | flowObjectiveService.filter(devId, igmp); |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 776 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 777 | } |
| 778 | |
| 779 | private boolean isConnectPoint(DeviceId device, PortNumber port) { |
Deepa Vaddireddy | 01f33b4 | 2017-07-02 13:26:53 +0530 | [diff] [blame] | 780 | if (connectPoint != null) { |
| 781 | return (connectPointMode && connectPoint.deviceId().equals(device) |
| 782 | && connectPoint.port().equals(port)); |
| 783 | } else { |
Andrea Campanella | 2c70a57 | 2020-06-05 13:31:45 +0200 | [diff] [blame^] | 784 | log.debug("connectPoint not configured for device {}", device); |
Deepa Vaddireddy | 01f33b4 | 2017-07-02 13:26:53 +0530 | [diff] [blame] | 785 | return false; |
| 786 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 787 | } |
Deepa Vaddireddy | 01f33b4 | 2017-07-02 13:26:53 +0530 | [diff] [blame] | 788 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 789 | private boolean isUplink(DeviceId device, PortNumber port) { |
Esin Karaman | ce5ce51 | 2020-02-25 15:58:14 +0000 | [diff] [blame] | 790 | if (connectPointMode) { |
| 791 | return false; |
| 792 | } |
| 793 | Optional<PortNumber> upLinkPort = getDeviceUplink(device); |
| 794 | return upLinkPort.isPresent() && upLinkPort.get().equals(port); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 795 | } |
| 796 | |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 797 | /** |
| 798 | * Fetches device information associated with the device serial number from SADIS. |
| 799 | * |
| 800 | * @param serialNumber serial number of a device |
| 801 | * @return device information; an empty Optional otherwise. |
| 802 | */ |
| 803 | private Optional<SubscriberAndDeviceInformation> getSubscriberAndDeviceInformation(String serialNumber) { |
| 804 | long start = System.currentTimeMillis(); |
| 805 | try { |
| 806 | return Optional.ofNullable(sadisService.getSubscriberInfoService().get(serialNumber)); |
| 807 | } finally { |
| 808 | if (log.isDebugEnabled()) { |
| 809 | // SADIS can call remote systems to fetch device data and this calls can take a long time. |
| 810 | // This measurement is just for monitoring these kinds of situations. |
| 811 | log.debug("Device fetched from SADIS. Elapsed {} msec", System.currentTimeMillis() - start); |
| 812 | } |
| 813 | |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | /** |
| 818 | * Fetches device information associated with the device serial number from SADIS. |
| 819 | * |
| 820 | * @param deviceId device id |
| 821 | * @return device information; an empty Optional otherwise. |
| 822 | */ |
| 823 | private Optional<SubscriberAndDeviceInformation> getSubscriberAndDeviceInformation(DeviceId deviceId) { |
| 824 | Device device = deviceService.getDevice(deviceId); |
| 825 | if (device == null || device.serialNumber() == null) { |
| 826 | return Optional.empty(); |
| 827 | } |
| 828 | return getSubscriberAndDeviceInformation(device.serialNumber()); |
| 829 | } |
| 830 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 831 | private class InternalDeviceListener implements DeviceListener { |
| 832 | @Override |
| 833 | public void event(DeviceEvent event) { |
Esin Karaman | 09b41e5 | 2020-06-01 10:52:55 +0000 | [diff] [blame] | 834 | eventExecutor.execute(() -> { |
| 835 | DeviceId devId = event.subject().id(); |
| 836 | Port p = event.port(); |
Deepa Vaddireddy | ca7b25d | 2017-09-28 13:47:18 +0000 | [diff] [blame] | 837 | |
Esin Karaman | 09b41e5 | 2020-06-01 10:52:55 +0000 | [diff] [blame] | 838 | if (!igmpLeadershipService.isLocalLeader(devId)) { |
| 839 | return; |
| 840 | } |
| 841 | if (getSubscriberAndDeviceInformation(devId).isEmpty() && |
| 842 | !(p != null && isConnectPoint(devId, p.number()))) { |
| 843 | return; |
| 844 | } |
| 845 | PortNumber port; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 846 | |
Esin Karaman | 09b41e5 | 2020-06-01 10:52:55 +0000 | [diff] [blame] | 847 | switch (event.type()) { |
| 848 | |
| 849 | case DEVICE_ADDED: |
| 850 | case DEVICE_UPDATED: |
| 851 | case DEVICE_REMOVED: |
| 852 | case DEVICE_SUSPENDED: |
| 853 | case DEVICE_AVAILABILITY_CHANGED: |
| 854 | case PORT_STATS_UPDATED: |
| 855 | break; |
| 856 | case PORT_ADDED: |
| 857 | port = p.number(); |
| 858 | if (getSubscriberAndDeviceInformation(devId).isPresent() && |
| 859 | !isUplink(devId, port) && !isConnectPoint(devId, port)) { |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 860 | processFilterObjective(devId, port, false); |
Esin Karaman | 09b41e5 | 2020-06-01 10:52:55 +0000 | [diff] [blame] | 861 | } else if (isUplink(devId, port)) { |
| 862 | provisionUplinkFlows(); |
| 863 | } else if (isConnectPoint(devId, port)) { |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 864 | provisionConnectPointFlows(); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 865 | } |
Esin Karaman | 09b41e5 | 2020-06-01 10:52:55 +0000 | [diff] [blame] | 866 | onSourceStateChanged(devId, port, true); |
| 867 | break; |
| 868 | case PORT_UPDATED: |
| 869 | port = p.number(); |
| 870 | if (getSubscriberAndDeviceInformation(devId).isPresent() && |
| 871 | !isUplink(devId, port) && !isConnectPoint(devId, port)) { |
| 872 | processFilterObjective(devId, port, !event.port().isEnabled()); |
| 873 | } else if (isUplink(devId, port)) { |
| 874 | if (event.port().isEnabled()) { |
| 875 | provisionUplinkFlows(devId); |
| 876 | } else { |
| 877 | processFilterObjective(devId, port, true); |
| 878 | } |
| 879 | } else if (isConnectPoint(devId, port)) { |
| 880 | if (event.port().isEnabled()) { |
| 881 | provisionConnectPointFlows(); |
| 882 | } else { |
| 883 | unprovisionConnectPointFlows(); |
| 884 | } |
| 885 | } |
| 886 | onSourceStateChanged(devId, port, event.port().isEnabled()); |
| 887 | break; |
| 888 | case PORT_REMOVED: |
| 889 | port = p.number(); |
| 890 | processFilterObjective(devId, port, true); |
| 891 | onSourceStateChanged(devId, port, false); |
| 892 | break; |
| 893 | default: |
| 894 | log.info("Unknown device event {}", event.type()); |
| 895 | break; |
| 896 | } |
| 897 | }); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 898 | } |
| 899 | |
| 900 | @Override |
| 901 | public boolean isRelevant(DeviceEvent event) { |
| 902 | return true; |
| 903 | } |
| 904 | } |
| 905 | |
Esin Karaman | 09b41e5 | 2020-06-01 10:52:55 +0000 | [diff] [blame] | 906 | private Set<McastRoute> multicastRoutesOfIgmpProxy() { |
| 907 | Set<McastRoute> routes = new HashSet<>(); //using set to eliminate multiple entities |
| 908 | groupMemberStore.getAllGroupMemberIds().forEach(groupMemberId -> { |
| 909 | GroupMember groupMember = groupMemberStore.getGroupMember(groupMemberId); |
| 910 | if (groupMember != null) { |
| 911 | groupMember.getSourceList().forEach(source -> { |
| 912 | //regenerate the routes created by this application |
| 913 | routes.add(new McastRoute(source, groupMemberId.getGroupIp(), McastRoute.Type.IGMP)); |
| 914 | }); |
| 915 | } |
| 916 | }); |
| 917 | return routes; |
| 918 | } |
| 919 | |
| 920 | private void onSourceStateChanged(DeviceId deviceId, PortNumber portNumber, boolean enabled) { |
| 921 | if (!(getSource().isPresent() && |
| 922 | getSource().get().deviceId().equals(deviceId) && |
| 923 | getSource().get().port().equals(portNumber))) { |
| 924 | //connect point is not configured as the source |
| 925 | log.debug("{}/{} is not the source cp. Stopped processing it further", deviceId, portNumber); |
| 926 | return; |
| 927 | } |
| 928 | log.info("source device:port is {}. DeviceId={}, portNumber={}", |
| 929 | (enabled ? "enabled. Restoring the source" : |
| 930 | "disabled. Deleting it from multicast routes"), deviceId, portNumber); |
| 931 | |
| 932 | Set<McastRoute> routes = multicastRoutesOfIgmpProxy(); |
| 933 | routes.forEach(route -> { |
| 934 | if (enabled) { |
| 935 | //add source to the route |
| 936 | multicastService.addSources(route, Sets.newHashSet(new ConnectPoint(deviceId, portNumber))); |
| 937 | } else { |
| 938 | //remove the source from the route |
| 939 | multicastService.removeSources(route, Sets.newHashSet(new ConnectPoint(deviceId, portNumber))); |
| 940 | } |
| 941 | }); |
| 942 | } |
| 943 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 944 | private class InternalNetworkConfigListener implements NetworkConfigListener { |
| 945 | |
| 946 | private void reconfigureNetwork(IgmpproxyConfig cfg) { |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 947 | IgmpproxyConfig newCfg = cfg == null ? new IgmpproxyConfig() : cfg; |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 948 | |
| 949 | unSolicitedTimeout = newCfg.unsolicitedTimeOut(); |
| 950 | maxResp = newCfg.maxResp(); |
| 951 | keepAliveInterval = newCfg.keepAliveInterval(); |
| 952 | keepAliveCount = newCfg.keepAliveCount(); |
| 953 | lastQueryInterval = newCfg.lastQueryInterval(); |
| 954 | lastQueryCount = newCfg.lastQueryCount(); |
| 955 | withRAUplink = newCfg.withRAUplink(); |
| 956 | withRADownlink = newCfg.withRADownlink(); |
| 957 | igmpCos = newCfg.igmpCos(); |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame] | 958 | igmpUniCos = newCfg.igmpUniCos(); // defines priority bit of IGMP query message sent to UNI ports |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 959 | periodicQuery = newCfg.periodicQuery(); |
| 960 | fastLeave = newCfg.fastLeave(); |
ke han | 29af27b | 2017-09-08 10:29:12 +0800 | [diff] [blame] | 961 | pimSSmInterworking = newCfg.pimSsmInterworking(); |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 962 | enableIgmpProvisioning = newCfg.enableIgmpProvisioning(); |
Esin Karaman | b38700c | 2019-09-17 13:01:25 +0000 | [diff] [blame] | 963 | igmpOnPodBasis = newCfg.igmpOnPodBasis(); |
Arjun E K | b0018fd | 2020-04-07 13:26:40 +0000 | [diff] [blame] | 964 | if (newCfg.outgoingIgmpWithV3() != null && |
| 965 | outgoingIgmpWithV3 != newCfg.outgoingIgmpWithV3()) { |
| 966 | outgoingIgmpWithV3 = newCfg.outgoingIgmpWithV3(); |
| 967 | } |
Deepa Vaddireddy | ca7b25d | 2017-09-28 13:47:18 +0000 | [diff] [blame] | 968 | |
| 969 | if (connectPointMode != newCfg.connectPointMode() || |
| 970 | connectPoint != newCfg.connectPoint()) { |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 971 | connectPointMode = newCfg.connectPointMode(); |
Deepa Vaddireddy | ca7b25d | 2017-09-28 13:47:18 +0000 | [diff] [blame] | 972 | connectPoint = newCfg.connectPoint(); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 973 | if (connectPointMode) { |
| 974 | unprovisionUplinkFlows(); |
| 975 | provisionConnectPointFlows(); |
| 976 | } else { |
| 977 | unprovisionConnectPointFlows(); |
| 978 | provisionUplinkFlows(); |
| 979 | } |
| 980 | } |
| 981 | if (connectPoint != null) { |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 982 | log.info("connect point : {}", connectPoint); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 983 | } |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 984 | log.info("mode: {}", connectPointMode); |
| 985 | |
| 986 | getSourceConnectPoint(newCfg); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 987 | |
| 988 | IgmpSender.getInstance().setIgmpCos(igmpCos); |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame] | 989 | IgmpSender.getInstance().setIgmpUniCos(igmpUniCos); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 990 | IgmpSender.getInstance().setMaxResp(maxResp); |
| 991 | IgmpSender.getInstance().setMvlan(mvlan); |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame] | 992 | IgmpSender.getInstance().setMvlanInner(mvlanInner); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 993 | IgmpSender.getInstance().setWithRADownlink(withRADownlink); |
| 994 | IgmpSender.getInstance().setWithRAUplink(withRAUplink); |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 995 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 996 | |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 997 | void getSourceConnectPoint(IgmpproxyConfig cfg) { |
Esin Karaman | 09b41e5 | 2020-06-01 10:52:55 +0000 | [diff] [blame] | 998 | ConnectPoint oldSourceDevPort = sourceDeviceAndPort; |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 999 | sourceDeviceAndPort = cfg.getSourceDeviceAndPort(); |
| 1000 | if (sourceDeviceAndPort != null) { |
| 1001 | log.debug("source parameter configured to {}", sourceDeviceAndPort); |
| 1002 | } |
Esin Karaman | 09b41e5 | 2020-06-01 10:52:55 +0000 | [diff] [blame] | 1003 | if (oldSourceDevPort != null && !oldSourceDevPort.equals(sourceDeviceAndPort)) { |
| 1004 | //source config has changed, remove the old source from multicast routes |
| 1005 | onSourceStateChanged(oldSourceDevPort.deviceId(), oldSourceDevPort.port(), false); |
| 1006 | } |
| 1007 | if (sourceDeviceAndPort != null && !sourceDeviceAndPort.equals(oldSourceDevPort)) { |
| 1008 | //add new source to the existing routes |
| 1009 | onSourceStateChanged(sourceDeviceAndPort.deviceId(), sourceDeviceAndPort.port(), true); |
| 1010 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 1011 | } |
| 1012 | |
| 1013 | public void reconfigureSsmTable(IgmpproxySsmTranslateConfig cfg) { |
| 1014 | if (cfg == null) { |
| 1015 | return; |
| 1016 | } |
| 1017 | Collection<McastRoute> translations = cfg.getSsmTranslations(); |
| 1018 | for (McastRoute route : translations) { |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 1019 | ssmTranslateTable.put(route.group().getIp4Address(), route.source().get().getIp4Address()); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 1020 | } |
| 1021 | } |
| 1022 | |
| 1023 | @Override |
| 1024 | public void event(NetworkConfigEvent event) { |
| 1025 | switch (event.type()) { |
| 1026 | case CONFIG_ADDED: |
| 1027 | case CONFIG_UPDATED: |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 1028 | // NOTE how to know if something has changed in sadis? |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 1029 | |
| 1030 | if (event.configClass().equals(IGMPPROXY_CONFIG_CLASS)) { |
| 1031 | IgmpproxyConfig config = networkConfig.getConfig(appId, IGMPPROXY_CONFIG_CLASS); |
| 1032 | if (config != null) { |
Esin Karaman | eff1039 | 2019-06-27 18:09:13 +0000 | [diff] [blame] | 1033 | log.info("igmpproxy config received. {}", config); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 1034 | reconfigureNetwork(config); |
| 1035 | } |
| 1036 | } |
| 1037 | |
| 1038 | if (event.configClass().equals(IGMPPROXY_SSM_CONFIG_CLASS)) { |
| 1039 | IgmpproxySsmTranslateConfig config = networkConfig.getConfig(appId, IGMPPROXY_SSM_CONFIG_CLASS); |
| 1040 | if (config != null) { |
| 1041 | reconfigureSsmTable(config); |
| 1042 | } |
| 1043 | } |
| 1044 | |
| 1045 | if (event.configClass().equals(MCAST_CONFIG_CLASS)) { |
| 1046 | McastConfig config = networkConfig.getConfig(coreAppId, MCAST_CONFIG_CLASS); |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame] | 1047 | boolean vlanConfigChanged = config != null && mvlan != config.egressVlan().toShort(); |
| 1048 | boolean innerVlanConfigChanged = config != null && |
| 1049 | mvlanInner != config.egressInnerVlan().toShort(); |
| 1050 | |
| 1051 | if (vlanConfigChanged || innerVlanConfigChanged) { |
| 1052 | log.info("igmpproxy vlan config received. {}", config); |
| 1053 | //at least one of the vlan configs has changed. Call leave before setting new values |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 1054 | groupMemberStore.getAllGroupMembers().forEach(m -> leaveAction(m)); |
Esin Karaman | 586f1d6 | 2020-06-04 10:15:34 +0000 | [diff] [blame] | 1055 | if (vlanConfigChanged) { |
| 1056 | mvlan = config.egressVlan().toShort(); |
| 1057 | IgmpSender.getInstance().setMvlan(mvlan); |
| 1058 | } |
| 1059 | if (innerVlanConfigChanged) { |
| 1060 | mvlanInner = config.egressInnerVlan().toShort(); |
| 1061 | IgmpSender.getInstance().setMvlanInner(mvlanInner); |
| 1062 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 1063 | } |
| 1064 | } |
| 1065 | |
| 1066 | log.info("Reconfigured"); |
| 1067 | break; |
| 1068 | case CONFIG_REGISTERED: |
| 1069 | case CONFIG_UNREGISTERED: |
| 1070 | break; |
| 1071 | case CONFIG_REMOVED: |
Matteo Scandolo | 7482bbe | 2020-02-12 14:37:09 -0800 | [diff] [blame] | 1072 | // NOTE how to know if something has changed in sadis? |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 1073 | default: |
| 1074 | break; |
| 1075 | } |
| 1076 | } |
| 1077 | } |
| 1078 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 1079 | private void provisionUplinkFlows(DeviceId deviceId) { |
| 1080 | if (connectPointMode) { |
| 1081 | return; |
| 1082 | } |
| 1083 | |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 1084 | Optional<PortNumber> upLink = getDeviceUplink(deviceId); |
| 1085 | if (upLink.isPresent()) { |
| 1086 | processFilterObjective(deviceId, upLink.get(), false); |
| 1087 | } |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | private void provisionUplinkFlows() { |
| 1091 | if (connectPointMode) { |
| 1092 | return; |
| 1093 | } |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 1094 | deviceService.getAvailableDevices().forEach(device -> { |
| 1095 | Optional<SubscriberAndDeviceInformation> accessDevice = getSubscriberAndDeviceInformation(device.id()); |
| 1096 | if (accessDevice.isPresent()) { |
| 1097 | provisionUplinkFlows(device.id()); |
| 1098 | } |
| 1099 | }); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 1100 | } |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 1101 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 1102 | private void unprovisionUplinkFlows() { |
Esin Karaman | 00e16b7 | 2020-02-21 10:32:39 +0000 | [diff] [blame] | 1103 | deviceService.getAvailableDevices().forEach(device -> { |
| 1104 | Optional<SubscriberAndDeviceInformation> accessDevices = getSubscriberAndDeviceInformation(device.id()); |
| 1105 | if (accessDevices.isPresent()) { |
| 1106 | Optional<PortNumber> upLink = getDeviceUplink(device.id()); |
| 1107 | if (upLink.isPresent()) { |
| 1108 | processFilterObjective(device.id(), upLink.get(), true); |
| 1109 | } |
| 1110 | } |
| 1111 | }); |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 1112 | } |
| 1113 | |
| 1114 | private void provisionConnectPointFlows() { |
| 1115 | if ((!connectPointMode) || connectPoint == null) { |
| 1116 | return; |
| 1117 | } |
| 1118 | |
| 1119 | processFilterObjective(connectPoint.deviceId(), connectPoint.port(), false); |
| 1120 | } |
Ilayda Ozdemir | 4c5947c | 2020-05-05 13:14:32 +0000 | [diff] [blame] | 1121 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 1122 | private void unprovisionConnectPointFlows() { |
| 1123 | if (connectPoint == null) { |
| 1124 | return; |
| 1125 | } |
| 1126 | processFilterObjective(connectPoint.deviceId(), connectPoint.port(), true); |
| 1127 | } |
Shubham Sharma | 47f2caf | 2020-02-18 12:13:40 +0000 | [diff] [blame] | 1128 | |
ke han | 81a38b9 | 2017-03-10 18:41:44 +0800 | [diff] [blame] | 1129 | } |