5 #include "sandesh/sandesh_types.h"
6 #include "sandesh/sandesh.h"
20 bool run_with_vrouter) :
22 run_with_vrouter_(run_with_vrouter), ip_fabric_interface_index_(-1),
23 ip_fabric_interface_(NULL), max_retries_(kMaxRetries),
24 retry_timeout_(kRetryTimeout), aging_timeout_(kAgingTimeout) {
49 for (ArpEntrySet::iterator sit = it->second.begin();
50 sit != it->second.end();) {
52 it->second.erase(sit++);
63 boost::asio::io_context &io) {
87 for (ArpEntrySet::iterator sit = it->second.begin();
88 sit != it->second.end();) {
90 it->second.erase(sit++);
108 GetInet4UnicastRouteTable()->
122 int prev = aps->
refcount_.fetch_and_decrement();
133 vrf_state_(state), arp_req_timer_(NULL), vrf_id_(vrf_id),
134 vm_ip_(ip), plen_(plen) {
150 "Arp Entry timer for VM",
160 &wait_for_traffic_map,
162 &arp_transmitted_map) {
170 WaitForTrafficIntfMap::iterator it = wait_for_traffic_map.begin();
171 for (;it != wait_for_traffic_map.end(); it++) {
179 bool inserted = arp_transmitted_map.insert(it->first).second;
181 if (inserted ==
false) {
200 GetMacIpLearningTable()->GetPairedMacAddress(
208 GetMacIpLearningTable()->MacIpEntryUnreachable(
258 if (dynamic_cast<const InetUnicastRouteEntry *>(route)) {
262 for (Route::PathList::const_iterator it = route->
GetPathList().begin();
290 uint32_t intf_id = intf->
id();
291 WaitForTrafficIntfMap::const_iterator wait_for_traffic_it =
292 wait_for_traffic_map.find(intf_id);
293 if (wait_for_traffic_it == wait_for_traffic_map.end()) {
299 wait_for_traffic_it->second));
304 if (dynamic_cast<const InetUnicastRouteEntry *>(route)) {
309 if (new_wait_for_traffic_map.size() > 0) {
316 uint8_t plen) : vrf_state_(vrf_state),
317 sg_list_(), tag_list_(), policy_(false), resolve_route_(false) {
346 start_iter->first.vrf == rt->
vrf() &&
364 start_iter->first.vrf == rt->
vrf() &&
368 if (tmp->second->DeleteArpRoute()) {
447 static_cast<const Interface *>(intf_nh->
GetInterface()) : NULL;
480 static_cast<const VmInterface*
>(intf)->IsActive()) {
580 agent(agent_ptr), arp_proto(proto), vrf(vrf_entry), rt_table(table),
581 evpn_rt_table(evpn_table), route_table_listener_id(
DBTableBase::kInvalidId),
582 evpn_route_table_listener_id(
DBTableBase::kInvalidId),
583 table_delete_ref(this, table->
deleter()),
584 evpn_table_delete_ref(this, evpn_table->
deleter()),
586 l3_walk_completed_(false), evpn_walk_completed_(false) {
608 ArpKeySet::iterator key_it = intf_entry.
arp_key_list.begin();
632 ArpKeySet::iterator key_it = intf_entry.
arp_key_list.begin();
638 ArpEntry *arp_entry = arp_it->second;
649 ArpKey key(static_cast<VmInterface *>
650 (itf)->primary_ip_addr().to_ulong(), itf->
vrf());
684 if (vm_intf->
vrf()) {
687 state->
SetVrf(vm_intf->
vrf(), forwarding_vrf);
696 std::pair<InterfaceArpMap::iterator, bool> ret;
698 return ret.first->second;
785 iter->second.erase(entry);
787 if (iter->second.empty()) {
798 for (ArpEntrySet::iterator sit = it->second.begin();
799 sit != it->second.end(); sit++) {
820 if (state == NULL || state->
deleted ==
true)
844 if (state == NULL || state->
deleted ==
true)
856 ArpKeySet::iterator key_it = intf_entry.
arp_key_list.find(entry->
key());
895 ARP_TRACE(
Trace,
"ARP state not cleared - VRF is not delete marked",
910 ARP_TRACE(
Trace,
"ARP state not cleared - Route table walk not complete",
978 intf_(intf), vrf_(NULL), fabric_vrf_(NULL), walk_ref_(NULL) {
1012 if (
vrf_->vn() &&
vrf_->vn()->bridging()) {
1048 if (
vrf_->forwarding_vrf() == NULL) {
uint8_t prefix_length() const
!
uint32_t arp_failure_count
~ArpPathPreferenceState()
std::pair< uint32_t, InterfaceArpInfo > InterfaceArpPair
void SetBounded(bool bounded)
const Interface * GetInterface() const
int intrusive_ptr_add_ref(const AsPath *cpath)
DBTableBase::ListenerId evpn_route_table_listener_id
const VnListType & dest_vn_list() const
DBTable::DBTableWalkRef managed_delete_walk_ref
const MacAddress & vm_mac() const
ProtoWorkQueue work_queue_
void SendMessage(PktModuleName mod, InterTaskMsg *msg)
void RouteUpdate(DBTablePartBase *part, DBEntryBase *entry)
std::pair< ArpPathPreferenceStateKey, ArpPathPreferenceState * > ArpPathPreferenceStatePair
const TagList & tag_list() const
void VrfNotify(DBTablePartBase *part, DBEntryBase *entry)
const PathPreference & path_preference() const
const IpAddress subnet_service_ip() const
AgentRouteTable * GetEvpnRouteTable() const
const ArpKey & key() const
DBState * GetState(DBTableBase *tbl_base, ListenerId listener) const
void NextHopNotify(DBEntryBase *entry)
AgentRouteTable * rt_table
const uint32_t id() const
NextHopTable * nexthop_table() const
DBTableBase * get_table() const
bool AddArpEntry(ArpEntry *entry)
Agent supports multiple route tables - Inet-unicast (IPv4/IPv6), Inet-multicast, bridge, EVPN (Type2/Type5). This base class contains common code for all types of route tables.
void set_ip_fabric_interface_index(uint32_t ind)
bool IsIp4SubnetMember(const Ip4Address &ip, const Ip4Address &prefix_ip, uint16_t plen)
ArpDBState(ArpVrfState *vrf_state, uint32_t vrf_id, IpAddress vm_ip_addr, uint8_t plen)
void SetState(DBTableBase *tbl_base, ListenerId listener, DBState *state)
boost::asio::ip::address IpAddress
MacLearningProto * mac_learning_proto() const
static const uint16_t kMaxFailures
ArpVrfState(Agent *agent, ArpProto *proto, VrfEntry *vrf, AgentRouteTable *table, AgentRouteTable *evpn_table)
const MacAddress & GetVifMac(const Agent *) const
Ip4Address prev_responded_ip
std::vector< int > SecurityGroupList
DBTable::DBTableWalkRef walk_ref_
void Update(const AgentRoute *route)
void set_ip_fabric_interface_mac(const MacAddress &mac)
DBTableWalkRef AllocWalker(WalkFn walk_fn, WalkCompleteFn walk_complete)
boost::asio::io_context * io_service()
void IncrementStatsArpReply(uint32_t idx)
InetUnicastAgentRouteTable * GetInet4UnicastRouteTable() const
const ArpCache & arp_cache()
InterfaceTable * interface_table() const
const string & GetName() const
const MacAddress & mac() const
uint32_t ArpResolvedStatsCounter(uint32_t idx)
void InterfaceNotify(DBEntryBase *entry)
bool evpn_walk_completed() const
bool ValidateAndClearVrfState(VrfEntry *vrf, const ArpVrfState *vrf_state)
ArpProto * GetArpProto() const
LifetimeRef< ArpVrfState > table_delete_ref
static const uint32_t kMaxRetry
Base class for all Route entries in agent.
void Erase(const IpAddress &ip, uint8_t plen)
void SendArpRequestByPlen(const VmInterface *vm_interface, const MacAddress &smac, const ArpPathPreferenceState *data, const Ip4Address &tpa)
void Unregister(ListenerId listener)
void set_ip_fabric_interface(Interface *itf)
void ReleaseWalker(DBTableWalkRef &walk)
void IncrementStatsResolved()
const Ip4Address * GetIp() const
const Interface * GetInterface() const
LifetimeRef< ArpVrfState > evpn_table_delete_ref
void SendArpRequestForAllIntf(const AgentRoute *route)
Interface * ip_fabric_interface() const
ArpPathPreferenceState * Locate(const IpAddress &ip, uint8_t plen)
ListenerId Register(ChangeCallback callback, const std::string &name="unspecified")
const std::string & fabric_vrf_name() const
const Type GetType() const
const AgentPath * GetActivePath() const
void WalkAgain(DBTableWalkRef walk)
void WalkDone(DBTableBase *part)
bool DeleteEvpnRouteState(DBTablePartBase *part, DBEntryBase *entry)
std::pair< ArpKey, ArpEntry * > ArpCachePair
ArpPathPreferenceState * Get(const IpAddress ip, uint8_t plen=32)
std::map< ArpKey, ArpEntrySet >::iterator GratuitousArpIterator
bool IsDependentRt(void) const
void SetSize(size_t size)
ArpIterator FindLowerBoundArpEntry(const ArpKey &key)
static TaskScheduler * GetInstance()
void Reset(LifetimeActor *actor)
const std::string & fabric_interface_name() const
const NextHop * GetActiveNextHop() const
void HandleArpReply(Ip4Address sip, uint32_t itf)
Ip4Address router_id() const
WaitForTrafficIntfMap l3_wait_for_traffic_map_
ArpProto(Agent *agent, boost::asio::io_context &io, bool run_with_vrouter)
EventManager * event_manager() const
ArpPathPreferenceStateMap arp_path_preference_map_
bool DeleteArpEntry(ArpEntry *entry)
bool is_health_check_service() const
const Peer * peer() const
bool os_oper_state() const
void UpdateMac(const InterfaceNH *nh)
uint32_t ArpRequestStatsCounter(uint32_t idx)
void SetState(State state)
boost::intrusive_ptr< const Interface > InterfaceConstRef
PktHandler * pkt_handler() const
ArpEntry * FindArpEntry(const ArpKey &key)
MacAddress mac(void) const
void ClearInterfaceArpStats(uint32_t idx)
uint32_t ArpReplyStatsCounter(uint32_t idx)
AgentParam * params() const
const Interface * get_interface() const
ArpInterfaceState(Interface *intf)
const uint32_t vrf_id() const
static Timer * CreateTimer(boost::asio::io_context &service, const std::string &name, int task_id=Timer::GetTimerTaskId(), int task_instance=Timer::GetTimerInstanceId(), bool delete_on_completion=false)
void ClearState(DBTableBase *tbl_base, ListenerId listener)
const MacAddress & mac() const
InterfaceArpMap interface_arp_map_
void EvpnRouteUpdate(DBTablePartBase *part, DBEntryBase *entry)
virtual const PrefixType & prefix_address() const
Returns the value of a stored prefix address (IPv4, IPv6 or MAC address)
boost::asio::ip::address_v4 Ip4Address
bool TimerExpiry(ArpKey &key, uint32_t timer_type, const Interface *itf)
VrfTable * vrf_table() const
DBTableBase::ListenerId interface_table_listener_id_
InterfaceArpInfo & ArpMapIndexToEntry(uint32_t idx)
void DeleteGratuitousArpEntry(ArpEntry *entry)
ArpPathPreferenceState(ArpVrfState *state, uint32_t vrf_id, const IpAddress &vm_ip, uint8_t plen)
std::set< uint32_t > ArpTransmittedIntfMap
bool PreWalkDone(DBTableBase *partition)
std::pair< ArpKey, ArpEntrySet > GratuitousArpCachePair
#define ARP_TRACE(obj,...)
uint32_t services_queue_limit()
const MacAddress & GetDMac() const
uint8_t prefix_length() const
!
tbb::atomic< int > refcount_
const IpAddress & ip() const
VmInterface::VmiType vmi_type() const
ProtoHandler * AllocProtoHandler(boost::shared_ptr< PktInfo > info, boost::asio::io_context &io)
const VrfEntry * GetVrf() const
bool evpn_walk_completed_
bool Start(int time, Handler handler, ErrorHandler error_handler=NULL)
bool WalkNotify(DBTablePartBase *partition, DBEntryBase *entry)
void IncrementStatsVmGarpReq()
static const uint32_t kArpTryCount
const Interface * FindInterface(size_t index) const
VrfEntry * forwarding_vrf() const
void AddGratuitousArpEntry(ArpKey &key)
void intrusive_ptr_release(const AsPath *cpath)
void IncrementStatsArpRequest(uint32_t idx)
const std::string & name() const
void UpdateArpRoutes(const InetUnicastRouteEntry *route)
std::map< uint32_t, InterfaceArpPathPreferenceInfo > WaitForTrafficIntfMap
DBTableBase::ListenerId route_table_listener_id
void SendArp(uint16_t op, const MacAddress &smac, in_addr_t sip, const MacAddress &tmac, const MacAddress &dmac, in_addr_t tip, uint32_t itf, uint32_t vrf)
bool PolicyEnabled() const
void SetVrf(VrfEntry *vrf, VrfEntry *fabric_vrf)
virtual const NextHop * ComputeNextHop(Agent *agent) const
ArpProto::GratuitousArpIterator GratuitousArpEntryIterator(const ArpKey &key, bool *key_valid)
std::map< ArpKey, ArpEntry * >::iterator ArpIterator
void SendArpIpc(ArpProto::ArpMsgType type, in_addr_t ip, const VrfEntry *vrf, InterfaceConstRef itf)
DBTablePartBase * get_table_partition() const
bool Reschedule(int time)
static const uint32_t kTimeout
AgentRouteTable * evpn_rt_table
WaitForTrafficIntfMap evpn_wait_for_traffic_map_
std::set< ArpEntry * > ArpEntrySet
InetUnicastRouteEntry * GetUcRoute(const IpAddress &addr) const
DBTableBase::ListenerId vrf_table_listener_id_
ArpPathPreferenceStatePtr arp_path_preference_state_
ArpEntry * GratuitousArpEntry(const ArpKey &key, const Interface *intf)
ArpIterator FindUpperBoundArpEntry(const ArpKey &key)
void HandlePathPreferenceArpReply(const VrfEntry *vrf, uint32_t itf, Ip4Address sip)
SecurityGroupList sg_list_
void Delete(const InetUnicastRouteEntry *rt)
ArpVrfState * vrf_state()
const SecurityGroupList & sg_list() const
bool DeleteRouteState(DBTablePartBase *part, DBEntryBase *entry)
static void WalkDone(DBTableBase *partition, ArpVrfState *state)
GratuitousArpCache gratuitous_arp_cache_
static bool DeleteTimer(Timer *Timer)
const PathList & GetPathList() const
DBTableBase::ListenerId nexthop_table_listener_id_
DBTable::DBTableWalkRef evpn_walk_ref_
std::pair< uint32_t, InterfaceArpPathPreferenceInfo > WaitForTrafficIntfPair
std::vector< int > TagList
bool l3_walk_completed() const