6 #include <sys/socket.h>
8 #include <linux/netlink.h>
12 #include <sys/types.h>
15 #include <asm/types.h>
16 #include <boost/asio.hpp>
36 #include <ini_parser.h>
37 #include <vr_genetlink.h>
44 using namespace boost::asio::ip;
51 minor_devid_(minor_id),
53 table_entries_count_(0),
55 (*(ksync->agent()->event_manager())->io_service(),
91 if (!khpmem && unlink_node) {
92 const char *error_msg = vr_table_unlink(
table_path_.c_str());
94 LOG(ERROR,
"Error unmapping KSync memory: " << error_msg);
105 const char *table_str;
113 if (mmap_error_msg) {
114 LOG(ERROR,
"Error mapping KSync memory. Device: " <<
table_path_ <<
"; " << mmap_error_msg);
125 struct nl_client *cl;
129 assert((cl = nl_register_client()) != NULL);
131 assert(nl_socket(cl, AF_NETLINK, SOCK_DGRAM, NETLINK_GENERIC) > 0);
132 assert(nl_connect(cl, 0, 0, 0) == 0);
134 assert(vrouter_obtain_family_id(cl) > 0);
136 assert(nl_build_nlh(cl, cl->cl_genl_family_id, NLM_F_REQUEST) == 0);
137 assert(nl_build_genlh(cl, SANDESH_REQUEST, 0) == 0);
139 attr_len = nl_get_attr_hdr_size();
142 nl_build_attr(cl, encode_len, NL_ATTR_VR_MESSAGE_PROTOCOL);
145 if ((ret = nl_sendmsg(cl)) < 0) {
146 LOG(DEBUG,
"Error requesting Table message. Error : " << ret);
150 while ((ret = nl_recvmsg(cl)) > 0) {
168 Mmap(
true, hpmem,
true);
219 struct nl_client *cl;
223 assert((cl = nl_register_client()) != NULL);
225 assert(nl_build_nlh(cl, cl->cl_genl_family_id, NLM_F_REQUEST) == 0);
226 assert(nl_build_genlh(cl, SANDESH_REQUEST, 0) == 0);
228 attr_len = nl_get_attr_hdr_size();
230 nl_build_attr(cl, encode_len, NL_ATTR_VR_MESSAGE_PROTOCOL);
233 ksync_agent_vrouter_sock_path =
236 "dpdk_netlink" : ksync_agent_vrouter_sock_path;
238 #ifdef AGENT_VROUTER_TCP
243 boost::asio::local::stream_protocol::socket
245 boost::asio::local::stream_protocol::endpoint
246 endpoint(ksync_agent_vrouter_sock_path);
248 boost::system::error_code ec;
249 socket.connect(endpoint, ec);
254 socket.send(boost::asio::buffer(cl->cl_buf, cl->cl_buf_offset), 0, ec);
259 uint32_t len_read = 0;
260 uint32_t data_len =
sizeof(
struct nlmsghdr);
261 while (len_read < data_len) {
262 len_read = socket.read_some(boost::asio::buffer(cl->cl_buf + len_read,
263 cl->cl_buf_len), ec);
268 if (len_read >
sizeof(
struct nlmsghdr)) {
269 const struct nlmsghdr *nlh =
270 (
const struct nlmsghdr *)((cl->cl_buf));
271 data_len = nlh->nlmsg_len;
282 Mmap(
false, NULL,
false);
bool cat_is_agent_mocked() const
std::string cat_ksocketdir() const
const uint32_t vrouter_server_port() const
AgentParam * params() const
EventManager * event_manager() const
const Ip4Address vrouter_server_ip() const
boost::asio::io_context * io_service()
virtual void IncrementHoldFlowCounter()
void InitMem(void *hpmem)
virtual void DecrementHoldFlowCounter()
static const uint32_t kAuditTimeout
uint32_t table_entries_count_
virtual bool IsInactiveEntry(uint32_t idx, uint8_t &gen_id)=0
static const uint32_t kAuditYieldTimer
virtual int get_entry_size()=0
virtual int EncodeReq(nl_client *nl, uint32_t attr_len)=0
std::list< AuditEntry > audit_list_
void Mmap(bool unlink, void *khpmem, bool kernel_mode)
static const uint32_t kAuditYieldMax
static const uint32_t kAuditSweepTime
static const uint32_t kAuditYieldMin
KSyncMemory(KSync *ksync, uint32_t minor_id)
virtual void CreateProtoAuditEntry(uint32_t index, uint8_t gen_id)=0
virtual void UpdateAgentHoldFlowCounter()
virtual void SetTableSize()
static void NetlinkDecoder(char *data, SandeshContext *ctxt)
static AgentSandeshContext * GetAgentSandeshContext(uint32_t type)
static int GetNetlinkFamilyId()
static bool DeleteTimer(Timer *Timer)
bool Start(int time, Handler handler, ErrorHandler error_handler=NULL)
static const int kTestFlowTableSize
#define KSYNC_AGENT_VROUTER_SOCK_PATH
#define LOG(_Level, _Msg)
static uint64_t UTCTimestampUsec()