2 * Copyright © 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.netvirt.elan.evpn.listeners;
11 import javax.annotation.PreDestroy;
12 import javax.inject.Inject;
13 import javax.inject.Singleton;
14 import org.opendaylight.infrautils.utils.concurrent.Executors;
15 import org.opendaylight.mdsal.binding.api.DataBroker;
16 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
17 import org.opendaylight.netvirt.elan.evpn.utils.EvpnMacVrfUtils;
18 import org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
28 * When RT2 route (advertise of withdraw) is received from peer side.
29 * BGPManager will receive the RT2 msg.
30 * It will check if the EVPN is configured and Network is attached to EVPN or not.
31 * BGPManager will write in path (FibEntries.class).child(VrfTables.class).child(MacVrfEntry.class)
32 * which MacVrfEntryListener is listening to.
33 * When RT2 advertise route is received: add method of MacVrfEntryListener will install DMAC flows for the
34 * received dest MAC in all the DPN's (with this network footprint).
35 * When RT2 withdraw route is received: remove method of MacVrfEntryListener will remove DMAC flows for the
36 * received dest MAC in all the DPN's (with this network footprint).
39 public class MacVrfEntryListener extends AbstractAsyncDataTreeChangeListener<MacVrfEntry> {
40 private static final Logger LOG = LoggerFactory.getLogger(MacVrfEntryListener.class);
41 private final DataBroker broker;
42 private final EvpnMacVrfUtils evpnMacVrfUtils;
45 public MacVrfEntryListener(final DataBroker broker, final EvpnMacVrfUtils evpnMacVrfUtils) {
46 super(broker, LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(FibEntries.class)
47 .child(VrfTables.class).child(MacVrfEntry.class),
48 Executors.newListeningSingleThreadExecutor("MacVrfEntryListener", LOG));
50 this.evpnMacVrfUtils = evpnMacVrfUtils;
55 LOG.info("{} start", getClass().getSimpleName());
59 public void add(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
60 LOG.info("ADD: Adding DMAC Entry for MACVrfEntry {} ", macVrfEntry);
61 evpnMacVrfUtils.addEvpnDmacFlow(instanceIdentifier, macVrfEntry);
65 public void update(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry, MacVrfEntry t1) {
70 public void remove(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
71 LOG.info("REMOVE: Removing DMAC Entry for MACVrfEntry {} ", macVrfEntry);
72 evpnMacVrfUtils.removeEvpnDmacFlow(instanceIdentifier, macVrfEntry);
79 Executors.shutdownAndAwaitTermination(getExecutorService());