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.PostConstruct;
12 import javax.inject.Inject;
13 import javax.inject.Singleton;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
16 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
17 import org.opendaylight.netvirt.elan.evpn.utils.EvpnMacVrfUtils;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
27 * When RT2 route (advertise of withdraw) is received from peer side.
28 * BGPManager will receive the RT2 msg.
29 * It will check if the EVPN is configured and Network is attached to EVPN or not.
30 * BGPManager will write in path (FibEntries.class).child(VrfTables.class).child(MacVrfEntry.class)
31 * which MacVrfEntryListener is listening to.
32 * When RT2 advertise route is received: add method of MacVrfEntryListener will install DMAC flows for the
33 * received dest MAC in all the DPN's (with this network footprint).
34 * When RT2 withdraw route is received: remove method of MacVrfEntryListener will remove DMAC flows for the
35 * received dest MAC in all the DPN's (with this network footprint).
38 public class MacVrfEntryListener extends AsyncDataTreeChangeListenerBase<MacVrfEntry, MacVrfEntryListener> {
39 private static final Logger LOG = LoggerFactory.getLogger(MacVrfEntryListener.class);
40 private final DataBroker broker;
41 private final EvpnMacVrfUtils evpnMacVrfUtils;
44 public MacVrfEntryListener(final DataBroker broker, final EvpnMacVrfUtils evpnMacVrfUtils) {
46 this.evpnMacVrfUtils = evpnMacVrfUtils;
53 registerListener(LogicalDatastoreType.CONFIGURATION, broker);
57 protected InstanceIdentifier<MacVrfEntry> getWildCardPath() {
58 return InstanceIdentifier.create(FibEntries.class).child(VrfTables.class).child(MacVrfEntry.class);
62 protected MacVrfEntryListener getDataTreeChangeListener() {
63 return MacVrfEntryListener.this;
67 protected void add(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
68 LOG.info("ADD: Adding DMAC Entry for MACVrfEntry {} ", macVrfEntry);
69 evpnMacVrfUtils.addEvpnDmacFlow(instanceIdentifier, macVrfEntry);
73 protected void update(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry, MacVrfEntry t1) {
78 protected void remove(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
79 LOG.info("REMOVE: Removing DMAC Entry for MACVrfEntry {} ", macVrfEntry);
80 evpnMacVrfUtils.removeEvpnDmacFlow(instanceIdentifier, macVrfEntry);