Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -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 | */ |
| 16 | package org.onosproject.dhcprelay; |
| 17 | |
| 18 | import java.nio.ByteBuffer; |
| 19 | import java.util.Collection; |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 20 | import java.util.Collections; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 21 | import java.util.Dictionary; |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 22 | import java.util.List; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 23 | import java.util.Objects; |
| 24 | import java.util.Optional; |
| 25 | import java.util.Set; |
Yi Tseng | 525ff40 | 2017-10-23 19:39:39 -0700 | [diff] [blame] | 26 | import java.util.stream.Collectors; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 27 | import java.util.stream.Stream; |
| 28 | |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 29 | import com.google.common.collect.ImmutableList; |
Yi Tseng | 525ff40 | 2017-10-23 19:39:39 -0700 | [diff] [blame] | 30 | import com.google.common.collect.Streams; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 31 | import org.apache.felix.scr.annotations.Activate; |
| 32 | import org.apache.felix.scr.annotations.Component; |
| 33 | import org.apache.felix.scr.annotations.Deactivate; |
| 34 | import org.apache.felix.scr.annotations.Modified; |
| 35 | import org.apache.felix.scr.annotations.Property; |
| 36 | import org.apache.felix.scr.annotations.Reference; |
| 37 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 38 | import org.apache.felix.scr.annotations.Service; |
| 39 | import org.onlab.packet.ARP; |
| 40 | import org.onlab.packet.DHCP; |
| 41 | import org.onlab.packet.DHCP6; |
| 42 | import org.onlab.packet.IPacket; |
| 43 | import org.onlab.packet.IPv6; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 44 | import org.onlab.packet.Ethernet; |
| 45 | import org.onlab.packet.IPv4; |
Yi Tseng | 4f2a046 | 2017-08-31 11:21:00 -0700 | [diff] [blame] | 46 | import org.onlab.packet.Ip4Address; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 47 | import org.onlab.packet.MacAddress; |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 48 | import org.onlab.packet.IpPrefix; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 49 | import org.onlab.packet.UDP; |
| 50 | import org.onlab.packet.VlanId; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 51 | import org.onlab.util.Tools; |
| 52 | import org.onosproject.cfg.ComponentConfigService; |
| 53 | import org.onosproject.core.ApplicationId; |
| 54 | import org.onosproject.core.CoreService; |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 55 | import org.onosproject.dhcprelay.api.DhcpHandler; |
| 56 | import org.onosproject.dhcprelay.api.DhcpRelayService; |
Yi Tseng | 919b2df | 2017-09-07 16:22:51 -0700 | [diff] [blame] | 57 | import org.onosproject.dhcprelay.api.DhcpServerInfo; |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 58 | import org.onosproject.dhcprelay.config.DefaultDhcpRelayConfig; |
Taras Lemkin | 4178591 | 2018-03-26 14:52:58 +0000 | [diff] [blame^] | 59 | import org.onosproject.dhcprelay.config.DhcpServerConfig; |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 60 | import org.onosproject.dhcprelay.config.EnableDhcpFpmConfig; |
Taras Lemkin | 4178591 | 2018-03-26 14:52:58 +0000 | [diff] [blame^] | 61 | import org.onosproject.dhcprelay.config.IndirectDhcpRelayConfig; |
| 62 | import org.onosproject.dhcprelay.config.IgnoreDhcpConfig; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 63 | import org.onosproject.dhcprelay.store.DhcpRecord; |
| 64 | import org.onosproject.dhcprelay.store.DhcpRelayStore; |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 65 | import org.onosproject.dhcprelay.store.DhcpFpmPrefixStore; |
| 66 | import org.onosproject.routing.fpm.api.FpmRecord; |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 67 | import org.onosproject.net.Device; |
Yi Tseng | 4f2a046 | 2017-08-31 11:21:00 -0700 | [diff] [blame] | 68 | import org.onosproject.net.Host; |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 69 | import org.onosproject.net.config.Config; |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 70 | import org.onosproject.net.device.DeviceEvent; |
| 71 | import org.onosproject.net.device.DeviceListener; |
| 72 | import org.onosproject.net.device.DeviceService; |
Ray Milkey | facf286 | 2017-08-03 11:58:29 -0700 | [diff] [blame] | 73 | import org.onosproject.net.intf.Interface; |
| 74 | import org.onosproject.net.intf.InterfaceService; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 75 | import org.onosproject.net.ConnectPoint; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 76 | import org.onosproject.net.HostId; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 77 | import org.onosproject.net.config.ConfigFactory; |
| 78 | import org.onosproject.net.config.NetworkConfigEvent; |
| 79 | import org.onosproject.net.config.NetworkConfigListener; |
| 80 | import org.onosproject.net.config.NetworkConfigRegistry; |
| 81 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 82 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 83 | import org.onosproject.net.flow.TrafficSelector; |
| 84 | import org.onosproject.net.flow.TrafficTreatment; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 85 | import org.onosproject.net.host.HostService; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 86 | import org.onosproject.net.packet.DefaultOutboundPacket; |
| 87 | import org.onosproject.net.packet.OutboundPacket; |
| 88 | import org.onosproject.net.packet.PacketContext; |
| 89 | import org.onosproject.net.packet.PacketPriority; |
| 90 | import org.onosproject.net.packet.PacketProcessor; |
| 91 | import org.onosproject.net.packet.PacketService; |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 92 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 93 | import org.osgi.service.component.ComponentContext; |
| 94 | import org.slf4j.Logger; |
| 95 | import org.slf4j.LoggerFactory; |
Kalhee Kim | d94ceea | 2017-11-29 19:03:02 +0000 | [diff] [blame] | 96 | import java.util.concurrent.Executors; |
| 97 | import java.util.concurrent.ScheduledExecutorService; |
| 98 | import java.util.concurrent.TimeUnit; |
| 99 | import static org.onlab.util.Tools.groupedThreads; |
| 100 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 101 | |
| 102 | import com.google.common.collect.ImmutableSet; |
| 103 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 104 | import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY; |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 105 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 106 | /** |
| 107 | * DHCP Relay Agent Application Component. |
| 108 | */ |
| 109 | @Component(immediate = true) |
| 110 | @Service |
| 111 | public class DhcpRelayManager implements DhcpRelayService { |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 112 | public static final String DHCP_RELAY_APP = "org.onosproject.dhcprelay"; |
Yi Tseng | 06799d6 | 2017-09-01 16:02:56 -0700 | [diff] [blame] | 113 | public static final String ROUTE_STORE_IMPL = |
| 114 | "org.onosproject.routeservice.store.RouteStoreImpl"; |
Yi Tseng | 525ff40 | 2017-10-23 19:39:39 -0700 | [diff] [blame] | 115 | |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 116 | private static final TrafficSelector ARP_SELECTOR = DefaultTrafficSelector.builder() |
| 117 | .matchEthType(Ethernet.TYPE_ARP) |
| 118 | .build(); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 119 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 120 | private final InternalConfigListener cfgListener = new InternalConfigListener(); |
| 121 | |
| 122 | private final Set<ConfigFactory> factories = ImmutableSet.of( |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 123 | new ConfigFactory<ApplicationId, DefaultDhcpRelayConfig>(APP_SUBJECT_FACTORY, |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 124 | DefaultDhcpRelayConfig.class, |
| 125 | DefaultDhcpRelayConfig.KEY, |
| 126 | true) { |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 127 | @Override |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 128 | public DefaultDhcpRelayConfig createConfig() { |
| 129 | return new DefaultDhcpRelayConfig(); |
| 130 | } |
| 131 | }, |
| 132 | new ConfigFactory<ApplicationId, IndirectDhcpRelayConfig>(APP_SUBJECT_FACTORY, |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 133 | IndirectDhcpRelayConfig.class, |
| 134 | IndirectDhcpRelayConfig.KEY, |
| 135 | true) { |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 136 | @Override |
| 137 | public IndirectDhcpRelayConfig createConfig() { |
| 138 | return new IndirectDhcpRelayConfig(); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 139 | } |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 140 | }, |
| 141 | new ConfigFactory<ApplicationId, IgnoreDhcpConfig>(APP_SUBJECT_FACTORY, |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 142 | IgnoreDhcpConfig.class, |
| 143 | IgnoreDhcpConfig.KEY, |
| 144 | true) { |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 145 | @Override |
| 146 | public IgnoreDhcpConfig createConfig() { |
| 147 | return new IgnoreDhcpConfig(); |
| 148 | } |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 149 | }, |
| 150 | new ConfigFactory<ApplicationId, EnableDhcpFpmConfig>(APP_SUBJECT_FACTORY, |
| 151 | EnableDhcpFpmConfig.class, |
| 152 | EnableDhcpFpmConfig.KEY, |
| 153 | false) { |
| 154 | @Override |
| 155 | public EnableDhcpFpmConfig createConfig() { |
| 156 | return new EnableDhcpFpmConfig(); |
| 157 | } |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 158 | } |
| 159 | ); |
| 160 | |
Kalhee Kim | d94ceea | 2017-11-29 19:03:02 +0000 | [diff] [blame] | 161 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 162 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 163 | protected NetworkConfigRegistry cfgService; |
| 164 | |
| 165 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 166 | protected CoreService coreService; |
| 167 | |
| 168 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 169 | protected PacketService packetService; |
| 170 | |
| 171 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 172 | protected HostService hostService; |
| 173 | |
| 174 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 175 | protected InterfaceService interfaceService; |
| 176 | |
| 177 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 178 | protected DhcpRelayStore dhcpRelayStore; |
| 179 | |
| 180 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 181 | protected ComponentConfigService compCfgService; |
| 182 | |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 183 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 184 | protected DeviceService deviceService; |
| 185 | |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 186 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 187 | protected DhcpFpmPrefixStore dhcpFpmPrefixStore; |
| 188 | |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 189 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY, |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 190 | target = "(version=4)") |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 191 | protected DhcpHandler v4Handler; |
| 192 | |
| 193 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY, |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 194 | target = "(version=6)") |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 195 | protected DhcpHandler v6Handler; |
| 196 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 197 | @Property(name = "arpEnabled", boolValue = true, |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 198 | label = "Enable Address resolution protocol") |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 199 | protected boolean arpEnabled = true; |
| 200 | |
Kalhee Kim | d94ceea | 2017-11-29 19:03:02 +0000 | [diff] [blame] | 201 | @Property(name = "dhcpPollInterval", intValue = 24 * 3600, |
| 202 | label = "dhcp relay poll interval") |
| 203 | protected int dhcpPollInterval = 24 * 3600; |
| 204 | |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 205 | @Property(name = "dhcpFpmEnabled", boolValue = false, |
| 206 | label = "Enable DhcpRelay Fpm") |
| 207 | protected boolean dhcpFpmEnabled = false; |
| 208 | |
Kalhee Kim | d94ceea | 2017-11-29 19:03:02 +0000 | [diff] [blame] | 209 | private ScheduledExecutorService timerExecutor; |
| 210 | |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 211 | protected DeviceListener deviceListener = new InternalDeviceListener(); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 212 | private DhcpRelayPacketProcessor dhcpRelayPacketProcessor = new DhcpRelayPacketProcessor(); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 213 | private ApplicationId appId; |
| 214 | |
Kalhee Kim | d94ceea | 2017-11-29 19:03:02 +0000 | [diff] [blame] | 215 | /** |
| 216 | * One second timer. |
| 217 | */ |
| 218 | class Dhcp6Timer implements Runnable { |
| 219 | @Override |
| 220 | public void run() { |
| 221 | v6Handler.timeTick(); |
| 222 | } |
| 223 | }; |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 224 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 225 | @Activate |
| 226 | protected void activate(ComponentContext context) { |
| 227 | //start the dhcp relay agent |
| 228 | appId = coreService.registerApplication(DHCP_RELAY_APP); |
| 229 | |
| 230 | cfgService.addListener(cfgListener); |
| 231 | factories.forEach(cfgService::registerConfigFactory); |
| 232 | //update the dhcp server configuration. |
| 233 | updateConfig(); |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 234 | |
| 235 | //add the packet processor |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 236 | packetService.addProcessor(dhcpRelayPacketProcessor, PacketProcessor.director(0)); |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 237 | |
Kalhee Kim | d94ceea | 2017-11-29 19:03:02 +0000 | [diff] [blame] | 238 | timerExecutor = Executors.newScheduledThreadPool(1, |
| 239 | groupedThreads("dhcpRelay", |
| 240 | "config-reloader-%d", log)); |
| 241 | timerExecutor.scheduleAtFixedRate(new Dhcp6Timer(), |
| 242 | 0, |
| 243 | dhcpPollInterval, |
| 244 | TimeUnit.SECONDS); |
| 245 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 246 | modified(context); |
| 247 | |
Yi Tseng | 06799d6 | 2017-09-01 16:02:56 -0700 | [diff] [blame] | 248 | // Enable distribute route store |
| 249 | compCfgService.preSetProperty(ROUTE_STORE_IMPL, |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 250 | "distributed", Boolean.TRUE.toString()); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 251 | compCfgService.registerProperties(getClass()); |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 252 | |
| 253 | deviceService.addListener(deviceListener); |
Kalhee Kim | d94ceea | 2017-11-29 19:03:02 +0000 | [diff] [blame] | 254 | |
| 255 | |
| 256 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 257 | log.info("DHCP-RELAY Started"); |
| 258 | } |
| 259 | |
| 260 | @Deactivate |
| 261 | protected void deactivate() { |
| 262 | cfgService.removeListener(cfgListener); |
| 263 | factories.forEach(cfgService::unregisterConfigFactory); |
| 264 | packetService.removeProcessor(dhcpRelayPacketProcessor); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 265 | cancelArpPackets(); |
Yi Tseng | dfa8ee2 | 2017-08-07 12:45:01 -0700 | [diff] [blame] | 266 | compCfgService.unregisterProperties(getClass(), false); |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 267 | deviceService.removeListener(deviceListener); |
Kalhee Kim | d94ceea | 2017-11-29 19:03:02 +0000 | [diff] [blame] | 268 | timerExecutor.shutdown(); |
| 269 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 270 | log.info("DHCP-RELAY Stopped"); |
| 271 | } |
| 272 | |
| 273 | @Modified |
| 274 | protected void modified(ComponentContext context) { |
| 275 | Dictionary<?, ?> properties = context.getProperties(); |
| 276 | Boolean flag; |
| 277 | |
| 278 | flag = Tools.isPropertyEnabled(properties, "arpEnabled"); |
| 279 | if (flag != null) { |
| 280 | arpEnabled = flag; |
| 281 | log.info("Address resolution protocol is {}", |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 282 | arpEnabled ? "enabled" : "disabled"); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | if (arpEnabled) { |
| 286 | requestArpPackets(); |
| 287 | } else { |
| 288 | cancelArpPackets(); |
| 289 | } |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 290 | |
Kalhee Kim | d94ceea | 2017-11-29 19:03:02 +0000 | [diff] [blame] | 291 | int intervalVal = Tools.getIntegerProperty(properties, "dhcpPollInterval"); |
| 292 | log.info("DhcpRelay poll interval new {} old {}", intervalVal, dhcpPollInterval); |
| 293 | if (intervalVal != dhcpPollInterval) { |
| 294 | timerExecutor.shutdown(); |
| 295 | dhcpPollInterval = intervalVal; |
| 296 | timerExecutor = Executors.newScheduledThreadPool(1, |
| 297 | groupedThreads("dhcpRelay", |
| 298 | "config-reloader-%d", log)); |
| 299 | timerExecutor.scheduleAtFixedRate(new Dhcp6Timer(), |
| 300 | 0, |
| 301 | dhcpPollInterval > 1 ? dhcpPollInterval : 1, |
| 302 | TimeUnit.SECONDS); |
| 303 | v6Handler.setDhcp6PollInterval(dhcpPollInterval); |
| 304 | } |
| 305 | |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 306 | flag = Tools.isPropertyEnabled(properties, "dhcpFpmEnabled"); |
| 307 | if (flag != null) { |
| 308 | boolean oldValue = dhcpFpmEnabled; |
| 309 | dhcpFpmEnabled = flag; |
| 310 | log.info("DhcpRelay FPM is {}", |
| 311 | dhcpFpmEnabled ? "enabled" : "disabled"); |
| 312 | |
| 313 | if (dhcpFpmEnabled && !oldValue) { |
| 314 | log.info("Dhcp Fpm is enabled."); |
| 315 | processDhcpFpmRoutes(true); |
| 316 | } |
| 317 | if (!dhcpFpmEnabled && oldValue) { |
| 318 | log.info("Dhcp Fpm is disabled."); |
| 319 | processDhcpFpmRoutes(false); |
| 320 | } |
| 321 | v6Handler.setDhcpFpmEnabled(dhcpFpmEnabled); |
| 322 | } |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 323 | } |
| 324 | |
Yi Tseng | 525ff40 | 2017-10-23 19:39:39 -0700 | [diff] [blame] | 325 | private static List<TrafficSelector> buildClientDhcpSelectors() { |
| 326 | return Streams.concat(Dhcp4HandlerImpl.DHCP_SELECTORS.stream(), |
| 327 | Dhcp6HandlerImpl.DHCP_SELECTORS.stream()) |
| 328 | .collect(Collectors.toList()); |
| 329 | } |
| 330 | |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 331 | /** |
| 332 | * Updates DHCP relay app configuration. |
| 333 | */ |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 334 | private void updateConfig() { |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 335 | DefaultDhcpRelayConfig defaultConfig = |
| 336 | cfgService.getConfig(appId, DefaultDhcpRelayConfig.class); |
| 337 | IndirectDhcpRelayConfig indirectConfig = |
| 338 | cfgService.getConfig(appId, IndirectDhcpRelayConfig.class); |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 339 | IgnoreDhcpConfig ignoreDhcpConfig = |
| 340 | cfgService.getConfig(appId, IgnoreDhcpConfig.class); |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 341 | |
| 342 | if (defaultConfig != null) { |
| 343 | updateConfig(defaultConfig); |
| 344 | } |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 345 | if (indirectConfig != null) { |
| 346 | updateConfig(indirectConfig); |
| 347 | } |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 348 | if (ignoreDhcpConfig != null) { |
| 349 | updateConfig(ignoreDhcpConfig); |
| 350 | } |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | /** |
| 354 | * Updates DHCP relay app configuration with given configuration. |
| 355 | * |
| 356 | * @param config the configuration ot update |
| 357 | */ |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 358 | protected void updateConfig(Config config) { |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 359 | if (config instanceof IndirectDhcpRelayConfig) { |
| 360 | IndirectDhcpRelayConfig indirectConfig = (IndirectDhcpRelayConfig) config; |
| 361 | v4Handler.setIndirectDhcpServerConfigs(indirectConfig.dhcpServerConfigs()); |
| 362 | v6Handler.setIndirectDhcpServerConfigs(indirectConfig.dhcpServerConfigs()); |
Yi Tseng | 3df7f9d | 2017-08-17 13:08:31 -0700 | [diff] [blame] | 363 | } else if (config instanceof DefaultDhcpRelayConfig) { |
| 364 | DefaultDhcpRelayConfig defaultConfig = (DefaultDhcpRelayConfig) config; |
| 365 | v4Handler.setDefaultDhcpServerConfigs(defaultConfig.dhcpServerConfigs()); |
| 366 | v6Handler.setDefaultDhcpServerConfigs(defaultConfig.dhcpServerConfigs()); |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 367 | } |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 368 | if (config instanceof IgnoreDhcpConfig) { |
Yi Tseng | 525ff40 | 2017-10-23 19:39:39 -0700 | [diff] [blame] | 369 | v4Handler.updateIgnoreVlanConfig((IgnoreDhcpConfig) config); |
| 370 | v6Handler.updateIgnoreVlanConfig((IgnoreDhcpConfig) config); |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 371 | } |
| 372 | } |
| 373 | |
| 374 | protected void removeConfig(Config config) { |
| 375 | if (config instanceof IndirectDhcpRelayConfig) { |
| 376 | v4Handler.setIndirectDhcpServerConfigs(Collections.emptyList()); |
| 377 | v6Handler.setIndirectDhcpServerConfigs(Collections.emptyList()); |
| 378 | } else if (config instanceof DefaultDhcpRelayConfig) { |
| 379 | v4Handler.setDefaultDhcpServerConfigs(Collections.emptyList()); |
| 380 | v6Handler.setDefaultDhcpServerConfigs(Collections.emptyList()); |
| 381 | } |
| 382 | if (config instanceof IgnoreDhcpConfig) { |
Yi Tseng | 525ff40 | 2017-10-23 19:39:39 -0700 | [diff] [blame] | 383 | v4Handler.updateIgnoreVlanConfig(null); |
| 384 | v6Handler.updateIgnoreVlanConfig(null); |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 385 | } |
| 386 | } |
| 387 | |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 388 | private void processDhcpFpmRoutes(Boolean add) { |
| 389 | // needs to restore/remove fpm |
| 390 | } |
| 391 | |
| 392 | public boolean isDhcpFpmEnabled() { |
| 393 | return dhcpFpmEnabled; |
| 394 | } |
| 395 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 396 | /** |
| 397 | * Request ARP packet in via PacketService. |
| 398 | */ |
| 399 | private void requestArpPackets() { |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 400 | packetService.requestPackets(ARP_SELECTOR, PacketPriority.CONTROL, appId); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Cancel requested ARP packets in via packet service. |
| 405 | */ |
| 406 | private void cancelArpPackets() { |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 407 | packetService.cancelPackets(ARP_SELECTOR, PacketPriority.CONTROL, appId); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | @Override |
| 411 | public Optional<DhcpRecord> getDhcpRecord(HostId hostId) { |
| 412 | return dhcpRelayStore.getDhcpRecord(hostId); |
| 413 | } |
| 414 | |
| 415 | @Override |
| 416 | public Collection<DhcpRecord> getDhcpRecords() { |
| 417 | return dhcpRelayStore.getDhcpRecords(); |
| 418 | } |
Kalhee Kim | d94ceea | 2017-11-29 19:03:02 +0000 | [diff] [blame] | 419 | @Override |
| 420 | public void updateDhcpRecord(HostId hostId, DhcpRecord dhcpRecord) { |
| 421 | dhcpRelayStore.updateDhcpRecord(hostId, dhcpRecord); |
| 422 | } |
Yi Tseng | 13a41a1 | 2017-07-26 13:45:01 -0700 | [diff] [blame] | 423 | @Override |
| 424 | public Optional<MacAddress> getDhcpServerMacAddress() { |
Yi Tseng | 4f2a046 | 2017-08-31 11:21:00 -0700 | [diff] [blame] | 425 | // TODO: depreated it |
| 426 | DefaultDhcpRelayConfig config = cfgService.getConfig(appId, DefaultDhcpRelayConfig.class); |
| 427 | DhcpServerConfig serverConfig = config.dhcpServerConfigs().get(0); |
| 428 | Ip4Address serverip = serverConfig.getDhcpServerIp4().get(); |
| 429 | return hostService.getHostsByIp(serverip) |
| 430 | .stream() |
| 431 | .map(Host::mac) |
| 432 | .findFirst(); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 433 | } |
| 434 | |
Yi Tseng | 919b2df | 2017-09-07 16:22:51 -0700 | [diff] [blame] | 435 | @Override |
| 436 | public List<DhcpServerInfo> getDefaultDhcpServerInfoList() { |
| 437 | return ImmutableList.<DhcpServerInfo>builder() |
| 438 | .addAll(v4Handler.getDefaultDhcpServerInfoList()) |
| 439 | .addAll(v6Handler.getDefaultDhcpServerInfoList()) |
| 440 | .build(); |
| 441 | } |
| 442 | |
| 443 | @Override |
| 444 | public List<DhcpServerInfo> getIndirectDhcpServerInfoList() { |
| 445 | return ImmutableList.<DhcpServerInfo>builder() |
| 446 | .addAll(v4Handler.getIndirectDhcpServerInfoList()) |
| 447 | .addAll(v6Handler.getIndirectDhcpServerInfoList()) |
| 448 | .build(); |
| 449 | } |
| 450 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 451 | /** |
| 452 | * Gets DHCP data from a packet. |
| 453 | * |
| 454 | * @param packet the packet |
| 455 | * @return the DHCP data; empty if it is not a DHCP packet |
| 456 | */ |
| 457 | private Optional<DHCP> findDhcp(Ethernet packet) { |
| 458 | return Stream.of(packet) |
| 459 | .filter(Objects::nonNull) |
| 460 | .map(Ethernet::getPayload) |
| 461 | .filter(p -> p instanceof IPv4) |
| 462 | .map(IPacket::getPayload) |
| 463 | .filter(Objects::nonNull) |
| 464 | .filter(p -> p instanceof UDP) |
| 465 | .map(IPacket::getPayload) |
| 466 | .filter(Objects::nonNull) |
| 467 | .filter(p -> p instanceof DHCP) |
| 468 | .map(p -> (DHCP) p) |
| 469 | .findFirst(); |
| 470 | } |
| 471 | |
| 472 | /** |
| 473 | * Gets DHCPv6 data from a packet. |
| 474 | * |
| 475 | * @param packet the packet |
| 476 | * @return the DHCPv6 data; empty if it is not a DHCPv6 packet |
| 477 | */ |
| 478 | private Optional<DHCP6> findDhcp6(Ethernet packet) { |
| 479 | return Stream.of(packet) |
| 480 | .filter(Objects::nonNull) |
| 481 | .map(Ethernet::getPayload) |
| 482 | .filter(p -> p instanceof IPv6) |
| 483 | .map(IPacket::getPayload) |
| 484 | .filter(Objects::nonNull) |
| 485 | .filter(p -> p instanceof UDP) |
| 486 | .map(IPacket::getPayload) |
| 487 | .filter(Objects::nonNull) |
| 488 | .filter(p -> p instanceof DHCP6) |
| 489 | .map(p -> (DHCP6) p) |
| 490 | .findFirst(); |
| 491 | } |
| 492 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 493 | |
| 494 | private class DhcpRelayPacketProcessor implements PacketProcessor { |
| 495 | |
| 496 | @Override |
| 497 | public void process(PacketContext context) { |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 498 | // process the packet and get the payload |
| 499 | Ethernet packet = context.inPacket().parsed(); |
| 500 | if (packet == null) { |
| 501 | return; |
| 502 | } |
| 503 | |
| 504 | findDhcp(packet).ifPresent(dhcpPayload -> { |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 505 | v4Handler.processDhcpPacket(context, dhcpPayload); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 506 | }); |
| 507 | |
| 508 | findDhcp6(packet).ifPresent(dhcp6Payload -> { |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 509 | v6Handler.processDhcpPacket(context, dhcp6Payload); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 510 | }); |
| 511 | |
| 512 | if (packet.getEtherType() == Ethernet.TYPE_ARP && arpEnabled) { |
| 513 | ARP arpPacket = (ARP) packet.getPayload(); |
| 514 | VlanId vlanId = VlanId.vlanId(packet.getVlanID()); |
| 515 | Set<Interface> interfaces = interfaceService. |
| 516 | getInterfacesByPort(context.inPacket().receivedFrom()); |
| 517 | //ignore the packets if dhcp server interface is not configured on onos. |
| 518 | if (interfaces.isEmpty()) { |
| 519 | log.warn("server virtual interface not configured"); |
| 520 | return; |
| 521 | } |
| 522 | if ((arpPacket.getOpCode() != ARP.OP_REQUEST)) { |
| 523 | // handle request only |
| 524 | return; |
| 525 | } |
| 526 | MacAddress interfaceMac = interfaces.stream() |
| 527 | .filter(iface -> iface.vlan().equals(vlanId)) |
| 528 | .map(Interface::mac) |
| 529 | .filter(mac -> !mac.equals(MacAddress.NONE)) |
| 530 | .findFirst() |
Yi Tseng | 5130129 | 2017-07-28 13:02:59 -0700 | [diff] [blame] | 531 | .orElse(MacAddress.ONOS); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 532 | if (interfaceMac == null) { |
| 533 | // can't find interface mac address |
| 534 | return; |
| 535 | } |
| 536 | processArpPacket(context, packet, interfaceMac); |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | /** |
| 541 | * Processes the ARP Payload and initiates a reply to the client. |
| 542 | * |
| 543 | * @param context the packet context |
| 544 | * @param packet the ethernet payload |
| 545 | * @param replyMac mac address to be replied |
| 546 | */ |
| 547 | private void processArpPacket(PacketContext context, Ethernet packet, MacAddress replyMac) { |
| 548 | ARP arpPacket = (ARP) packet.getPayload(); |
Ray Milkey | f0c4761 | 2017-09-28 11:29:38 -0700 | [diff] [blame] | 549 | ARP arpReply = arpPacket.duplicate(); |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 550 | arpReply.setOpCode(ARP.OP_REPLY); |
| 551 | |
| 552 | arpReply.setTargetProtocolAddress(arpPacket.getSenderProtocolAddress()); |
| 553 | arpReply.setTargetHardwareAddress(arpPacket.getSenderHardwareAddress()); |
| 554 | arpReply.setSenderProtocolAddress(arpPacket.getTargetProtocolAddress()); |
| 555 | arpReply.setSenderHardwareAddress(replyMac.toBytes()); |
| 556 | |
| 557 | // Ethernet Frame. |
| 558 | Ethernet ethReply = new Ethernet(); |
| 559 | ethReply.setSourceMACAddress(replyMac.toBytes()); |
| 560 | ethReply.setDestinationMACAddress(packet.getSourceMAC()); |
| 561 | ethReply.setEtherType(Ethernet.TYPE_ARP); |
| 562 | ethReply.setVlanID(packet.getVlanID()); |
| 563 | ethReply.setPayload(arpReply); |
| 564 | |
| 565 | ConnectPoint targetPort = context.inPacket().receivedFrom(); |
| 566 | TrafficTreatment t = DefaultTrafficTreatment.builder() |
| 567 | .setOutput(targetPort.port()).build(); |
| 568 | OutboundPacket o = new DefaultOutboundPacket( |
| 569 | targetPort.deviceId(), t, ByteBuffer.wrap(ethReply.serialize())); |
| 570 | if (log.isTraceEnabled()) { |
| 571 | log.trace("Relaying ARP packet {} to {}", packet, targetPort); |
| 572 | } |
| 573 | packetService.emit(o); |
| 574 | } |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | /** |
| 578 | * Listener for network config events. |
| 579 | */ |
| 580 | private class InternalConfigListener implements NetworkConfigListener { |
| 581 | @Override |
| 582 | public void event(NetworkConfigEvent event) { |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 583 | switch (event.type()) { |
| 584 | case CONFIG_UPDATED: |
| 585 | case CONFIG_ADDED: |
| 586 | event.config().ifPresent(config -> { |
| 587 | updateConfig(config); |
| 588 | log.info("{} updated", config.getClass().getSimpleName()); |
| 589 | }); |
| 590 | break; |
| 591 | case CONFIG_REMOVED: |
| 592 | event.prevConfig().ifPresent(config -> { |
| 593 | removeConfig(config); |
| 594 | log.info("{} removed", config.getClass().getSimpleName()); |
| 595 | }); |
| 596 | break; |
Charles Chan | e437a80 | 2018-04-21 00:44:29 -0700 | [diff] [blame] | 597 | case CONFIG_REGISTERED: |
| 598 | case CONFIG_UNREGISTERED: |
| 599 | break; |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 600 | default: |
| 601 | log.warn("Unsupported event type {}", event.type()); |
| 602 | break; |
Yi Tseng | 483ac6f | 2017-08-02 15:03:31 -0700 | [diff] [blame] | 603 | } |
Charles Chan | 50443e8 | 2018-01-03 16:26:32 -0800 | [diff] [blame] | 604 | } |
Yi Tseng | 51f1be9 | 2017-09-01 17:24:57 -0700 | [diff] [blame] | 605 | |
Charles Chan | 50443e8 | 2018-01-03 16:26:32 -0800 | [diff] [blame] | 606 | @Override |
| 607 | public boolean isRelevant(NetworkConfigEvent event) { |
| 608 | if (event.configClass().equals(DefaultDhcpRelayConfig.class) || |
| 609 | event.configClass().equals(IndirectDhcpRelayConfig.class) || |
| 610 | event.configClass().equals(IgnoreDhcpConfig.class)) { |
| 611 | return true; |
| 612 | } |
| 613 | log.debug("Ignore irrelevant event class {}", event.configClass().getName()); |
| 614 | return false; |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 615 | } |
| 616 | } |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 617 | |
| 618 | private class InternalDeviceListener implements DeviceListener { |
| 619 | |
| 620 | @Override |
| 621 | public void event(DeviceEvent event) { |
| 622 | Device device = event.subject(); |
| 623 | switch (event.type()) { |
| 624 | case DEVICE_ADDED: |
Yi Tseng | 525ff40 | 2017-10-23 19:39:39 -0700 | [diff] [blame] | 625 | updateIgnoreVlanConfigs(); |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 626 | break; |
| 627 | case DEVICE_AVAILABILITY_CHANGED: |
| 628 | deviceAvailabilityChanged(device); |
Ray Milkey | d6a67c3 | 2018-02-02 10:30:35 -0800 | [diff] [blame] | 629 | break; |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 630 | default: |
| 631 | break; |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | private void deviceAvailabilityChanged(Device device) { |
| 636 | if (deviceService.isAvailable(device.id())) { |
Yi Tseng | 525ff40 | 2017-10-23 19:39:39 -0700 | [diff] [blame] | 637 | updateIgnoreVlanConfigs(); |
Saurav Das | b805f1a | 2017-12-13 16:19:35 -0800 | [diff] [blame] | 638 | } else { |
| 639 | removeIgnoreVlanState(); |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 640 | } |
| 641 | } |
| 642 | |
Yi Tseng | 525ff40 | 2017-10-23 19:39:39 -0700 | [diff] [blame] | 643 | private void updateIgnoreVlanConfigs() { |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 644 | IgnoreDhcpConfig config = cfgService.getConfig(appId, IgnoreDhcpConfig.class); |
Yi Tseng | 525ff40 | 2017-10-23 19:39:39 -0700 | [diff] [blame] | 645 | v4Handler.updateIgnoreVlanConfig(config); |
| 646 | v6Handler.updateIgnoreVlanConfig(config); |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 647 | } |
Saurav Das | b805f1a | 2017-12-13 16:19:35 -0800 | [diff] [blame] | 648 | |
| 649 | private void removeIgnoreVlanState() { |
| 650 | IgnoreDhcpConfig config = cfgService.getConfig(appId, IgnoreDhcpConfig.class); |
| 651 | v4Handler.removeIgnoreVlanState(config); |
| 652 | v6Handler.removeIgnoreVlanState(config); |
| 653 | } |
Yi Tseng | 127ffe5 | 2017-09-12 15:55:17 -0700 | [diff] [blame] | 654 | } |
Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 655 | |
| 656 | |
| 657 | |
| 658 | public Optional<FpmRecord> getFpmRecord(IpPrefix prefix) { |
| 659 | return dhcpFpmPrefixStore.getFpmRecord(prefix); |
| 660 | } |
| 661 | |
| 662 | public Collection<FpmRecord> getFpmRecords() { |
| 663 | return dhcpFpmPrefixStore.getFpmRecords(); |
| 664 | } |
| 665 | |
| 666 | @Override |
| 667 | public void addFpmRecord(IpPrefix prefix, FpmRecord fpmRecord) { |
| 668 | dhcpFpmPrefixStore.addFpmRecord(prefix, fpmRecord); |
| 669 | } |
| 670 | |
| 671 | @Override |
| 672 | public Optional<FpmRecord> removeFpmRecord(IpPrefix prefix) { |
| 673 | return dhcpFpmPrefixStore.removeFpmRecord(prefix); |
| 674 | } |
Kalhee Kim | d94ceea | 2017-11-29 19:03:02 +0000 | [diff] [blame] | 675 | |
| 676 | |
Yi Tseng | 7a38f9a | 2017-06-09 14:36:40 -0700 | [diff] [blame] | 677 | } |