OpenSDN source code
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
mac_ip_learning_proto_handler.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 Juniper Networks, Inc. All rights reserved.
3
*/
4
#include "
mac_learning_init.h
"
5
#include "
mac_learning_proto.h
"
6
#include "
mac_ip_learning_proto_handler.h
"
7
8
MacIpLearningProtoHandler::MacIpLearningProtoHandler
(
Agent
*agent,
9
boost::shared_ptr<PktInfo> info,
10
boost::asio::io_context &io):
11
ProtoHandler
(agent, info, io), intf_(NULL), vrf_(NULL), table_(NULL),
12
entry_() {
13
}
14
15
void
MacIpLearningProtoHandler::Log
(std::string msg) {
16
17
std::string vrf =
""
;
18
std::string intf =
""
;
19
if
(
vrf_
!= NULL) {
20
vrf =
vrf_
->
GetName
();
21
}
22
23
if
(
intf_
!= NULL) {
24
intf =
intf_
->
name
();
25
}
26
27
MAC_IP_LEARNING_TRACE(
MacLearningTraceBuf
, vrf,
pkt_info_
->ip_saddr.to_string(),
28
pkt_info_
->smac.ToString(), intf, msg);
29
}
30
31
bool
MacIpLearningProtoHandler::Run
() {
32
intf_
=
agent
()->
interface_table
()->
33
FindInterface(
pkt_info_
->agent_hdr.ifindex);
34
if
(
intf_
== NULL) {
35
Log
(
"Invalid interface"
);
36
return
true
;
37
}
38
39
vrf_
=
agent
()->
vrf_table
()->
FindVrfFromId
(
pkt_info_
->agent_hdr.vrf);
40
if
(
vrf_
== NULL) {
41
Log
(
"Invalid VRF"
);
42
return
true
;
43
}
44
45
const
VmInterface
*vm_intf =
dynamic_cast<
const
VmInterface
*
>
(
intf_
);
46
if
(vm_intf == NULL) {
47
Log
(
"Ingress packet on non-VMI interface"
);
48
return
true
;
49
}
50
uint32_t vrf_id = 0;
51
if
(
pkt_info_
->agent_hdr.vrf == 0) {
52
vrf_id = vm_intf->
vrf_id
();
53
}
else
{
54
vrf_id =
pkt_info_
->agent_hdr.vrf;
55
}
56
table_
=
agent
()->
mac_learning_proto
()->
GetMacIpLearningTable
();
57
entry_
.reset(
new
MacIpLearningEntry
(
table_
, vrf_id,
58
pkt_info_
->ip_saddr,
59
pkt_info_
->smac,
60
intf_
));
61
if
(
entry_
.get()) {
62
agent
()->
mac_learning_proto
()->
GetMacIpLearningTable
()->
Add
(
entry_
);
63
Log
(
"Mac entry added"
);
64
}
65
66
return
true
;
67
}
MacIpLearningProtoHandler::Log
void Log(std::string str)
Definition:
mac_ip_learning_proto_handler.cc:15
Agent::mac_learning_proto
MacLearningProto * mac_learning_proto() const
Definition:
agent.h:1005
MacIpLearningEntry
Definition:
mac_ip_learning.h:18
Agent::interface_table
InterfaceTable * interface_table() const
Definition:
agent.h:465
VrfEntry::GetName
const string & GetName() const
Definition:
vrf.h:100
ProtoHandler::agent
Agent * agent() const
Definition:
proto_handler.h:80
ProtoHandler::pkt_info_
boost::shared_ptr< PktInfo > pkt_info_
Definition:
proto_handler.h:92
MacIpLearningTable::Add
void Add(MacLearningEntryPtr ptr)
Definition:
mac_ip_learning.cc:64
MacIpLearningProtoHandler::intf_
const Interface * intf_
Definition:
mac_ip_learning_proto_handler.h:26
VrfTable::FindVrfFromId
VrfEntry * FindVrfFromId(size_t index)
Definition:
vrf.cc:884
Agent
Definition:
agent.h:358
MacLearningProto::GetMacIpLearningTable
MacIpLearningTable * GetMacIpLearningTable()
Definition:
mac_learning_proto.cc:107
Interface::vrf_id
uint32_t vrf_id() const
Definition:
interface.cc:621
MacLearningTraceBuf
SandeshTraceBufferPtr MacLearningTraceBuf
mac_learning_proto.h
Agent::vrf_table
VrfTable * vrf_table() const
Definition:
agent.h:485
VmInterface
Definition:
vm_interface.h:358
MacIpLearningProtoHandler::table_
MacIpLearningTable * table_
Definition:
mac_ip_learning_proto_handler.h:28
MacIpLearningProtoHandler::vrf_
const VrfEntry * vrf_
Definition:
mac_ip_learning_proto_handler.h:27
mac_learning_init.h
Interface::name
const std::string & name() const
Definition:
interface.h:114
MacIpLearningProtoHandler::Run
bool Run()
Definition:
mac_ip_learning_proto_handler.cc:31
ProtoHandler
Definition:
proto_handler.h:28
MacIpLearningProtoHandler::entry_
MacLearningEntryPtr entry_
Definition:
mac_ip_learning_proto_handler.h:29
mac_ip_learning_proto_handler.h
MacIpLearningProtoHandler::MacIpLearningProtoHandler
MacIpLearningProtoHandler(Agent *agent, boost::shared_ptr< PktInfo > info, boost::asio::io_context &io)
Definition:
mac_ip_learning_proto_handler.cc:8
contrail
controller
src
vnsw
agent
mac_learning
mac_ip_learning_proto_handler.cc
Generated by
1.8.5