6 #include <sys/socket.h>
8 #include <linux/netlink.h>
9 #include <linux/rtnetlink.h>
10 #include <linux/genetlink.h>
11 #include <linux/sockios.h>
14 #include <boost/bind.hpp>
30 #include "vr_genetlink.h"
31 #include "vr_message.h"
34 #include "vr_interface.h"
40 using namespace boost::asio;
46 encoder.set_h_op(sandesh_op::RESPONSE);
47 encoder.set_resp_code(code);
48 return encoder.WriteBinary(buf, buf_len, &error);
52 tx_buff_list_.push_back(*cl);
64 assert(tx_buff_list_.size() == 0);
68 int decode_buf_len = buf_len;
69 decode_buf = (uint8_t *)(parse_buf);
70 while(decode_buf_len > 0) {
74 LOG(DEBUG,
"Incorrect decode len " << decode_len);
77 decode_buf += decode_len;
78 decode_buf_len -= decode_len;
91 struct nlmsghdr *last_nlh = NULL;
92 std::vector<struct nl_client>::iterator it = tx_buff_list_.begin();
94 while (it != tx_buff_list_.end()) {
95 struct nl_client *cl = &(*it);
96 struct nlmsghdr *nlh = (
struct nlmsghdr *)(cl->cl_buf);
98 nlh->nlmsg_flags |= NLM_F_MULTI;
100 iovec.push_back(buffer(cl->cl_buf, cl->cl_msg_len));
109 InitNetlinkDoneMsg(&nlh, last_nlh->nlmsg_seq);
110 iovec.push_back(buffer((uint8_t *)&nlh, NLMSG_HDRLEN));
114 last_nlh->nlmsg_flags &= (~NLM_F_MULTI);
118 KSyncBufferList::iterator iovec_it = iovec.begin();
119 while (iovec_it != iovec.end()) {
120 sock_.send_to(*iovec_it, local_ep_);
125 it = tx_buff_list_.begin();
126 while (it != tx_buff_list_.end()) {
127 struct nl_client *cl = &(*it);
131 tx_buff_list_.clear();
140 uint32_t buf_len = 0, encode_len = 0;
141 struct nlmsghdr *nlh;
144 if ((ret = nl_build_header(&cl, &buf, &buf_len)) < 0) {
145 LOG(DEBUG,
"Error creating interface DUMP message : " << ret);
150 nlh = (
struct nlmsghdr *)cl.cl_buf;
151 nlh->nlmsg_seq = seq_num;
153 uint32_t fwd_flow_idx = req->get_fr_index();
154 bool add_error =
false;
155 if (fwd_flow_idx == 0xFFFFFFFF) {
158 if (flow_error != -ENOSPC && flow_error != 0) {
173 buf_len -= encode_len;
175 vr_flow_response resp;
176 resp.set_fresp_op(flow_op::FLOW_SET);
177 resp.set_fresp_flags(req->get_fr_flags());
178 resp.set_fresp_index(req->get_fr_index());
179 resp.set_fresp_gen_id(req->get_fr_gen_id());
180 resp.set_fresp_bytes(0);
181 resp.set_fresp_packets(0);
182 resp.set_fresp_stats_oflow(0);
184 encode_len += resp.WriteBinary(buf, buf_len, &error);
186 SimulateResponse(seq_num, -ENOENT, 0);
191 nl_update_header(&cl, encode_len);
197 nlh->nlmsg_seq = seq_num;
198 nlh->nlmsg_type = NLMSG_DONE;
199 nlh->nlmsg_len = NLMSG_HDRLEN;
200 nlh->nlmsg_flags = 0;
210 if ((ret = nl_build_header(&cl, &buf, &buf_len)) < 0) {
211 LOG(DEBUG,
"Error creating mpls message. Error : " << ret);
216 struct nlmsghdr *nlh = (
struct nlmsghdr *)cl.cl_buf;
217 nlh->nlmsg_seq = seq_num;
218 nlh->nlmsg_flags |= flags;
220 nl_update_header(&cl, encode_len);
221 LOG(DEBUG,
"SimulateResponse " <<
" seq " << seq_num <<
" code " << std::hex << code);
229 ksync_rx_queue[i]->set_disable(disable);
245 KSyncSockTypeMap::ksync_map_if::const_iterator it;
246 static int os_index = 10;
248 sprintf(name,
"intf%d",
id);
249 vr_interface_req req;
250 req.set_vifr_idx(
id);
251 req.set_vifr_type(VIF_TYPE_VIRTUAL);
253 req.set_vifr_os_idx(os_index);
254 req.set_vifr_name(name);
255 const std::vector<signed char> list(mac_size);
256 req.set_vifr_mac(list);
257 req.set_vifr_flags(flags);
259 it = sock->
if_map.find(
id);
260 if (it == sock->
if_map.end()) {
268 KSyncSockTypeMap::ksync_map_if::iterator it;
269 it = sock->
if_map.find(
id);
270 if (it != sock->
if_map.end()) {
277 KSyncSockTypeMap::ksync_map_nh::const_iterator it;
280 req.set_nhr_flags(flags);
281 it = sock->
nh_map.find(
id);
282 if (it == sock->
nh_map.end()) {
289 KSyncSockTypeMap::ksync_map_nh::iterator it;
290 it = sock->
nh_map.find(
id);
291 if (it != sock->
nh_map.end()) {
298 KSyncSockTypeMap::ksync_map_mpls::const_iterator it;
300 req.set_mr_label(
id);
309 KSyncSockTypeMap::ksync_map_mpls::iterator it;
318 KSyncSockTypeMap::ksync_map_mirror::const_iterator it;
320 req.set_mirr_index(
id);
329 KSyncSockTypeMap::ksync_map_mirror::iterator it;
339 std::pair<std::set<vr_route_req>::iterator,
bool> ret;
340 ret = sock->
rt_tree.insert(req);
343 if (ret.second ==
false) {
344 int del_count = sock->
rt_tree.erase(req);
346 ret = sock->
rt_tree.insert(req);
347 assert(ret.second ==
true);
349 if (req.get_rtr_family() == AF_BRIDGE) {
356 KSyncSockTypeMap::ksync_rt_tree::iterator it;
358 if (it != sock->
rt_tree.end()) {
365 KSyncSockTypeMap::ksync_vrf_assign_tree::const_iterator it;
374 KSyncSockTypeMap::ksync_vrf_assign_tree::iterator it;
383 KSyncSockTypeMap::ksync_map_vrf_stats::const_iterator it;
384 vr_vrf_stats_req vrf_stats;
385 vrf_stats.set_vsr_vrf(vrf_id);
386 vrf_stats.set_vsr_family(AF_INET);
387 vrf_stats.set_vsr_rid(0);
388 vrf_stats.set_vsr_discards(0);
389 vrf_stats.set_vsr_resolves(0);
390 vrf_stats.set_vsr_receives(0);
391 vrf_stats.set_vsr_udp_tunnels(0);
392 vrf_stats.set_vsr_udp_mpls_tunnels(0);
393 vrf_stats.set_vsr_gre_mpls_tunnels(0);
394 vrf_stats.set_vsr_ecmp_composites(0);
395 vrf_stats.set_vsr_fabric_composites(0);
396 vrf_stats.set_vsr_l2_mcast_composites(0);
397 vrf_stats.set_vsr_encaps(0);
398 vrf_stats.set_vsr_l2_encaps(0);
408 KSyncSockTypeMap::ksync_map_vrf_stats::iterator it;
418 r.set_vsr_discards(req.get_vsr_discards());
419 r.set_vsr_resolves(req.get_vsr_resolves());
420 r.set_vsr_receives(req.get_vsr_receives());
421 r.set_vsr_udp_tunnels(req.get_vsr_udp_tunnels());
422 r.set_vsr_udp_mpls_tunnels(req.get_vsr_udp_mpls_tunnels());
423 r.set_vsr_gre_mpls_tunnels(req.get_vsr_gre_mpls_tunnels());
424 r.set_vsr_ecmp_composites(req.get_vsr_ecmp_composites());
425 r.set_vsr_l2_mcast_composites(req.get_vsr_l2_mcast_composites());
426 r.set_vsr_fabric_composites(req.get_vsr_fabric_composites());
427 r.set_vsr_encaps(req.get_vsr_encaps());
428 r.set_vsr_l2_encaps(req.get_vsr_l2_encaps());
429 r.set_vsr_gros(req.get_vsr_gros());
430 r.set_vsr_diags(req.get_vsr_diags());
431 r.set_vsr_encap_composites(req.get_vsr_encap_composites());
432 r.set_vsr_evpn_composites(req.get_vsr_evpn_composites());
433 r.set_vsr_vrf_translates(req.get_vsr_vrf_translates());
434 r.set_vsr_vxlan_tunnels(req.get_vsr_vxlan_tunnels());
435 r.set_vsr_arp_virtual_proxy(req.get_vsr_arp_virtual_proxy());
436 r.set_vsr_arp_virtual_stitch(req.get_vsr_arp_virtual_stitch());
437 r.set_vsr_arp_virtual_flood(req.get_vsr_arp_virtual_flood());
438 r.set_vsr_arp_physical_stitch(req.get_vsr_arp_physical_stitch());
439 r.set_vsr_arp_tor_proxy(req.get_vsr_arp_tor_proxy());
440 r.set_vsr_arp_physical_flood(req.get_vsr_arp_physical_flood());
441 r.set_vsr_l2_receives(req.get_vsr_l2_receives());
442 r.set_vsr_uuc_floods(req.get_vsr_uuc_floods());
447 KSyncSockTypeMap::ksync_map_vxlan::const_iterator it;
452 vxlan.set_vxlanr_vnid(
id);
453 vxlan.set_vxlanr_rid(0);
460 KSyncSockTypeMap::ksync_map_vxlan::iterator it;
469 int obytes,
int opkts,
int oerrors) {
471 vr_interface_req req = sock->
if_map[idx];
472 req.set_vifr_ibytes(ibytes+req.get_vifr_ibytes());
473 req.set_vifr_ipackets(ipkts+req.get_vifr_ipackets());
474 req.set_vifr_ierrors(ierrors+req.get_vifr_ierrors());
475 req.set_vifr_obytes(obytes+req.get_vifr_obytes());
476 req.set_vifr_opackets(opkts+req.get_vifr_opackets());
477 req.set_vifr_oerrors(oerrors+req.get_vifr_oerrors());
482 int obytes,
int opkts,
int oerrors) {
484 vr_interface_req req = sock->
if_map[idx];
485 req.set_vifr_ibytes(ibytes);
486 req.set_vifr_ipackets(ipkts);
487 req.set_vifr_ierrors(ierrors);
488 req.set_vifr_obytes(obytes);
489 req.set_vifr_opackets(opkts);
490 req.set_vifr_oerrors(oerrors);
496 return sock->
if_map.size();
501 return sock->
nh_map.size();
520 struct nlmsghdr *nlh = (
struct nlmsghdr *)data;
521 return nlh->nlmsg_seq;
525 struct nlmsghdr *nlh = (
struct nlmsghdr *)data;
527 return (nlh->nlmsg_flags & NLM_F_MULTI);
542 struct nlmsghdr *nlh = (
struct nlmsghdr *)data;
543 if (nlh->nlmsg_type == NLMSG_ERROR) {
544 LOG(ERROR,
"Ignoring Netlink error for seqno " << nlh->nlmsg_seq
545 <<
" len " << nlh->nlmsg_len);
550 if (nlh->nlmsg_len > kBufLen) {
551 LOG(ERROR,
"Length of " << nlh->nlmsg_len <<
" is more than expected "
552 "length of " << kBufLen);
559 KSyncBufferList::iterator it = iovec->begin();
561 while (it != iovec->end()) {
562 unsigned char *buf = boost::asio::buffer_cast<
unsigned char *>(*it);
563 assert((offset + boost::asio::buffer_size(*it)) < len);
564 memcpy(data + offset, buf, boost::asio::buffer_size(*it));
565 offset += boost::asio::buffer_size(*it);
579 ProcessSandesh((
const uint8_t *)(data), data_len, &ctx);
588 ProcessSandesh((
const uint8_t *)(data), data_len, &ctx);
594 sock_.async_receive_from(buf, local_ep_, cb);
603 flow_table_ = (vr_flow_entry *)malloc(size);
615 return &flow_table_[idx];
619 uint32_t idx = req->get_fr_index();
621 vr_flow_entry *f = &flow_table_[idx];
623 f->fe_flags &= ~VR_FLOW_FLAG_ACTIVE;
624 f->fe_stats.flow_bytes = 0;
625 f->fe_stats.flow_packets = 0;
630 int family = (req->get_fr_family() == AF_INET)?
Address::INET :
634 U64ToIp(req->get_fr_flow_sip_u(), req->get_fr_flow_sip_l(),
635 req->get_fr_flow_dip_u(), req->get_fr_flow_dip_l(),
637 f->fe_flags = VR_FLOW_FLAG_ACTIVE;
638 f->fe_stats.flow_bytes = 30;
639 f->fe_stats.flow_packets = 1;
640 f->fe_gen_id = req->get_fr_gen_id();
642 f->fe_key.flow4_sip = htonl(sip.to_v4().to_ulong());
643 f->fe_key.flow4_dip = htonl(dip.to_v4().to_ulong());
646 f->fe_key.flow4_nh_id = req->get_fr_flow_nh_id();
648 f->fe_key.flow6_nh_id = req->get_fr_flow_nh_id();
650 f->fe_key.flow_family = req->get_fr_family();
651 f->fe_key.flow_sport = req->get_fr_flow_sport();
652 f->fe_key.flow_dport = req->get_fr_flow_dport();
653 f->fe_key.flow_nh_id = req->get_fr_flow_nh_id();
654 f->fe_key.flow_proto = req->get_fr_flow_proto();
658 vr_flow_entry *f = &flow_table_[idx];
659 if (f->fe_flags & VR_FLOW_FLAG_ACTIVE) {
660 f->fe_flags |= VR_FLOW_FLAG_EVICTED;
665 vr_flow_entry *f = &flow_table_[idx];
666 if (f->fe_flags & VR_FLOW_FLAG_ACTIVE) {
667 f->fe_flags &= ~VR_FLOW_FLAG_EVICTED;
673 vr_flow_entry *f = &flow_table_[idx];
674 if (f->fe_flags & VR_FLOW_FLAG_ACTIVE) {
675 f->fe_stats.flow_bytes += bytes;
676 f->fe_stats.flow_packets += pkts;
681 vr_flow_entry *f = &flow_table_[idx];
682 if (f->fe_flags & VR_FLOW_FLAG_ACTIVE) {
683 f->fe_tcp_flags = flags;
688 vr_flow_entry *f = &flow_table_[idx];
689 if (f->fe_flags & VR_FLOW_FLAG_ACTIVE) {
690 f->fe_tcp_flags = flags;
695 vr_flow_entry *f = &flow_table_[idx];
696 if (f->fe_flags & VR_FLOW_FLAG_ACTIVE) {
697 f->fe_udp_src_port = port;
702 vr_flow_entry *f = &flow_table_[idx];
703 if (f->fe_flags & VR_FLOW_FLAG_ACTIVE) {
704 f->fe_stats.flow_bytes_oflow = bytes;
705 f->fe_stats.flow_packets_oflow = pkts;
710 bridge_table_ = (vr_bridge_entry *)malloc(size);
711 memset(bridge_table_, 0, size);
712 return bridge_table_;
718 bridge_table_ = NULL;
723 return &bridge_table_[idx];
728 vr_bridge_entry *be = &bridge_table_[idx];
734 if (be->be_packets == 0) {
737 vr_bridge_entry_key *key = &be->be_key;
740 key->be_vrf_id = req->get_rtr_vrf_id();
743 const std::vector<signed char> &prefix = req->get_rtr_mac();
744 for(std::vector<signed char>::const_iterator it = prefix.begin();
745 it != prefix.end(); ++it) {
746 key->be_mac[i] = ((uint8_t) *it);
752 vr_bridge_entry *be = &bridge_table_[idx];
754 be->be_flags |= VR_BE_MAC_NEW_FLAG;
756 be->be_flags &= ~VR_BE_MAC_NEW_FLAG;
762 assert(singleton_ == NULL);
768 singleton_->local_ep_.address
769 (boost::asio::ip::address::from_string(
"127.0.0.1"));
770 singleton_->local_ep_.port(0);
771 singleton_->sock_.open(boost::asio::ip::udp::v4());
772 singleton_->sock_.bind(singleton_->local_ep_);
773 singleton_->local_ep_ = singleton_->sock_.local_endpoint();
782 while (!ctx_queue_.empty()) {
783 ctx_queue_.front()->Process();
784 delete ctx_queue_.front();
791 tbb::mutex::scoped_lock lock(ctx_queue_lock_);
792 if (block_msg_processing_ != enable) {
793 block_msg_processing_ = enable;
794 if (!block_msg_processing_) {
804 if (req_->get_h_op() == sandesh_op::DEL) {
805 sock->
if_map.erase(req_->get_vifr_idx());
806 }
else if (req_->get_h_op() == sandesh_op::DUMP) {
810 }
else if (req_->get_h_op() == sandesh_op::GET) {
816 vr_interface_req if_info(*req_);
817 sock->
if_map[req_->get_vifr_idx()] = if_info;
840 flags = req_->get_fr_flags();
843 sock->
flow_map.erase(req_->get_fr_index());
847 uint32_t fwd_flow_idx = req_->get_fr_index();
848 if (fwd_flow_idx == 0xFFFFFFFF) {
849 if (flow_error == 0) {
853 fwd_flow_idx = req_->get_fr_rindex() + 1;
855 fwd_flow_idx = rand() % 20000;
859 fwd_flow_idx += 20000;
868 req_->set_fr_index(fwd_flow_idx);
869 req_->set_fr_gen_id((fwd_flow_idx % 255));
875 fwd_flow_idx = rand() % 20000;
879 fwd_flow_idx += 20000;
882 req_->set_fr_index(fwd_flow_idx);
883 req_->set_fr_gen_id((fwd_flow_idx % 255));
887 if (fwd_flow_idx != 0xFFFFFFFF) {
889 vr_flow_req flow_info(*req_);
891 sock->
flow_map[req_->get_fr_index()] = flow_info;
922 if (req_->get_h_op() == sandesh_op::DEL) {
923 sock->
nh_map.erase(req_->get_nhr_id());
924 }
else if (req_->get_h_op() == sandesh_op::DUMP) {
928 }
else if (req_->get_h_op() == sandesh_op::GET) {
934 vr_nexthop_req nh_info(*req_);
935 sock->
nh_map[req_->get_nhr_id()] = nh_info;
957 if (req_->get_h_op() == sandesh_op::DEL) {
958 sock->
mpls_map.erase(req_->get_mr_label());
959 }
else if (req_->get_h_op() == sandesh_op::DUMP) {
963 }
else if (req_->get_h_op() == sandesh_op::GET) {
969 vr_mpls_req mpls_info(*req_);
970 sock->
mpls_map[req_->get_mr_label()] = mpls_info;
992 if (req_->get_h_op() == sandesh_op::DEL) {
993 if (req_->get_rtr_family() == AF_BRIDGE) {
997 }
else if (req_->get_h_op() == sandesh_op::DUMP) {
1033 if (req->get_h_op() == sandesh_op::DEL) {
1034 sock->
mirror_map.erase(req->get_mirr_index());
1039 if (req->get_h_op() == sandesh_op::DUMP) {
1045 if (req->get_h_op() == sandesh_op::GET) {
1052 vr_mirror_req mirror_info(*req);
1053 sock->
mirror_map[req->get_mirr_index()] = mirror_info;
1061 if (req_->get_h_op() == sandesh_op::DEL) {
1062 sock->
vxlan_map.erase(req_->get_vxlanr_vnid());
1063 }
else if (req_->get_h_op() == sandesh_op::DUMP) {
1067 }
else if (req_->get_h_op() == sandesh_op::GET) {
1073 vr_vxlan_req vxlan_info(*req_);
1074 sock->
vxlan_map[req_->get_vxlanr_vnid()] = vxlan_info;
1096 if (req_->get_h_op() == sandesh_op::GET) {
1121 if (req_->get_h_op() == sandesh_op::DEL) {
1123 }
else if (req_->get_h_op() == sandesh_op::DUMP) {
1129 std::pair<std::set<vr_vrf_assign_req>::iterator,
bool> ret;
1133 if (ret.second ==
false) {
1137 assert(ret.second ==
true);
1161 if (req_->get_h_op() == sandesh_op::DEL) {
1162 sock->
vrf_map.erase(req_->get_vrf_idx());
1163 }
else if (req_->get_h_op() == sandesh_op::DUMP) {
1167 }
else if (req_->get_h_op() == sandesh_op::GET) {
1173 vr_vrf_req vrf_info(*req_);
1174 sock->
vrf_map[req_->get_vrf_idx()] = vrf_info;
1193 if (req_->get_h_op() == sandesh_op::DUMP) {
1196 }
else if (req_->get_h_op() == sandesh_op::GET) {
1217 if (req_->get_h_op() == sandesh_op::GET) {
1239 struct nl_client cl;
1241 uint8_t *buf = NULL;
1242 uint32_t buf_len = 0, encode_len = 0, tot_encode_len = 0;
1243 struct nlmsghdr *nlh = NULL;
1246 unsigned int resp_code = 0;
1250 ret_code &= ~VR_MESSAGE_DUMP_INCOMPLETE;
1254 Sandesh *req = GetFirst(from_req);
1257 if ((ret = nl_build_header(&cl, &buf, &buf_len)) < 0) {
1258 LOG(DEBUG,
"Error creating interface DUMP message : " << ret);
1263 nlh = (
struct nlmsghdr *)cl.cl_buf;
1264 nlh->nlmsg_seq = seq_num;
1267 while(req != NULL) {
1268 encode_len = req->
WriteBinary(buf, buf_len, &error);
1273 buf_len -= encode_len;
1274 tot_encode_len += encode_len;
1280 if (req != NULL && buf_len < encode_len) {
1296 resp_code = resp_code | VR_MESSAGE_DUMP_INCOMPLETE;
1302 nlh->nlmsg_flags |= NLM_F_MULTI;
1303 nl_update_header(&cl, tot_encode_len);
1312 struct nl_client cl;
1314 uint8_t *buf = NULL;
1315 uint32_t buf_len = 0, encode_len = 0;
1316 struct nlmsghdr *nlh;
1323 ret_code &= ~VR_MESSAGE_DUMP_INCOMPLETE;
1333 if ((ret = nl_build_header(&cl, &buf, &buf_len)) < 0) {
1334 LOG(DEBUG,
"Error creating interface DUMP message : " << ret);
1339 nlh = (
struct nlmsghdr *)cl.cl_buf;
1340 nlh->nlmsg_seq = seq_num;
1344 buf_len -= resp_len;
1346 encode_len = req->
WriteBinary(buf, buf_len, &error);
1353 buf_len -= encode_len;
1355 nl_update_header(&cl, encode_len + resp_len);
1361 KSyncSockTypeMap::ksync_map_if::const_iterator it;
1362 static vr_interface_req req;
1364 it = sock->
if_map.find(idx);
1365 if (it != sock->
if_map.end()) {
1374 KSyncSockTypeMap::ksync_map_if::const_iterator it;
1375 static vr_interface_req req;
1377 vr_interface_req *orig_req;
1378 orig_req =
static_cast<vr_interface_req *
>(from_req);
1380 idx = orig_req->get_vifr_marker();
1381 it = sock->
if_map.upper_bound(idx);
1383 if (it != sock->
if_map.end()) {
1385 req.set_vifr_flags(orig_req->get_vifr_flags());
1392 static int last_intf_id = 0;
1393 static int32_t last_if_flags = 0;
1395 KSyncSockTypeMap::ksync_map_if::const_iterator it;
1396 static vr_interface_req req, *r;
1398 r =
dynamic_cast<vr_interface_req *
>(input);
1404 last_intf_id = r->get_vifr_idx();
1405 last_if_flags = r->get_vifr_flags();
1406 if (r->get_vifr_flags() & VIF_FLAG_GET_DROP_STATS) {
1407 return &drop_stats_req;
1410 it = sock->
if_map.upper_bound(last_intf_id);
1412 if (it != sock->
if_map.end()) {
1414 req.set_vifr_flags(last_if_flags);
1422 KSyncSockTypeMap::ksync_map_nh::const_iterator it;
1423 static vr_nexthop_req req;
1425 it = sock->
nh_map.find(idx);
1426 if (it != sock->
nh_map.end()) {
1435 KSyncSockTypeMap::ksync_map_nh::const_iterator it;
1436 static vr_nexthop_req req;
1437 vr_nexthop_req *orig_req;
1438 orig_req =
static_cast<vr_nexthop_req *
>(from_req);
1441 idx = orig_req->get_nhr_marker();
1442 it = sock->
nh_map.upper_bound(idx);
1443 if (it != sock->
nh_map.end()) {
1452 KSyncSockTypeMap::ksync_map_nh::const_iterator it;
1453 static vr_nexthop_req req, *r;
1455 r =
static_cast<vr_nexthop_req *
>(input);
1456 it = sock->
nh_map.upper_bound(r->get_nhr_id());
1458 if (it != sock->
nh_map.end()) {
1467 KSyncSockTypeMap::ksync_map_mpls::const_iterator it;
1468 static vr_mpls_req req;
1480 KSyncSockTypeMap::ksync_map_mpls::const_iterator it;
1481 static vr_mpls_req req;
1482 vr_mpls_req *orig_req;
1483 orig_req =
static_cast<vr_mpls_req *
>(from_req);
1486 idx = orig_req->get_mr_marker();
1487 it = sock->
mpls_map.upper_bound(idx);
1498 KSyncSockTypeMap::ksync_map_mpls::const_iterator it;
1499 static vr_mpls_req req, *r;
1501 r =
static_cast<vr_mpls_req *
>(input);
1502 it = sock->
mpls_map.upper_bound(r->get_mr_label());
1513 KSyncSockTypeMap::ksync_map_vrf::const_iterator it;
1514 static vr_vrf_req req;
1517 if (it != sock->
vrf_map.end()) {
1526 KSyncSockTypeMap::ksync_map_vrf::const_iterator it;
1527 static vr_vrf_req req;
1528 vr_vrf_req *orig_req;
1529 orig_req =
static_cast<vr_vrf_req *
>(from_req);
1532 idx = orig_req->get_vrf_marker();
1533 it = sock->
vrf_map.upper_bound(idx);
1535 if (it != sock->
vrf_map.end()) {
1544 KSyncSockTypeMap::ksync_map_vrf::const_iterator it;
1545 static vr_vrf_req req, *r;
1547 r =
static_cast<vr_vrf_req *
>(input);
1548 it = sock->
vrf_map.upper_bound(r->get_vrf_idx());
1550 if (it != sock->
vrf_map.end()) {
1559 KSyncSockTypeMap::ksync_map_mirror::const_iterator it;
1560 static vr_mirror_req req;
1572 KSyncSockTypeMap::ksync_map_mirror::const_iterator it;
1573 static vr_mirror_req req;
1574 vr_mirror_req *orig_req;
1575 orig_req =
static_cast<vr_mirror_req *
>(from_req);
1578 idx = orig_req->get_mirr_marker();
1590 KSyncSockTypeMap::ksync_map_mirror::const_iterator it;
1591 static vr_mirror_req req, *r;
1593 r =
static_cast<vr_mirror_req *
>(input);
1594 it = sock->
mirror_map.upper_bound(r->get_mirr_index());
1605 KSyncSockTypeMap::ksync_rt_tree::const_iterator it;
1606 static vr_route_req req;
1607 vr_route_req *orig_req, key;
1608 orig_req =
static_cast<vr_route_req *
>(from_req);
1610 key.set_rtr_family(orig_req->get_rtr_family());
1611 key.set_rtr_vrf_id(orig_req->get_rtr_vrf_id());
1612 if (orig_req->get_rtr_marker().size() || orig_req->get_rtr_mac().size()) {
1613 if (orig_req->get_rtr_family() == AF_BRIDGE) {
1614 key.set_rtr_mac(orig_req->get_rtr_mac());
1616 key.set_rtr_prefix(orig_req->get_rtr_marker());
1617 key.set_rtr_prefix_len(orig_req->get_rtr_marker_plen());
1619 it = sock->
rt_tree.upper_bound(key);
1621 std::vector<int8_t> rtr_prefix;
1622 if (orig_req->get_rtr_family() == AF_BRIDGE) {
1623 key.set_rtr_mac(rtr_prefix);
1625 key.set_rtr_prefix(rtr_prefix);
1626 key.set_rtr_prefix_len(0);
1628 it = sock->
rt_tree.lower_bound(key);
1632 if (it != sock->
rt_tree.end()) {
1633 if ((it->get_rtr_vrf_id() != orig_req->get_rtr_vrf_id()) ||
1634 (it->get_rtr_family() != orig_req->get_rtr_family())) {
1645 KSyncSockTypeMap::ksync_rt_tree::const_iterator it;
1646 static vr_route_req req, *r, key;
1648 r =
static_cast<vr_route_req *
>(input);
1650 key.set_rtr_vrf_id(r->get_rtr_vrf_id());
1651 key.set_rtr_family(r->get_rtr_family());
1652 if (r->get_rtr_family() == AF_BRIDGE) {
1653 key.set_rtr_mac(r->get_rtr_mac());
1655 key.set_rtr_prefix(r->get_rtr_prefix());
1656 key.set_rtr_prefix_len(r->get_rtr_prefix_len());
1658 it = sock->
rt_tree.upper_bound(key);
1660 if (it != sock->
rt_tree.end()) {
1661 if ((it->get_rtr_vrf_id() != r->get_rtr_vrf_id()) ||
1662 (it->get_rtr_family() != r->get_rtr_family())) {
1673 KSyncSockTypeMap::ksync_vrf_assign_tree::const_iterator it;
1674 static vr_vrf_assign_req req;
1675 vr_vrf_assign_req *orig_req, key;
1676 orig_req =
static_cast<vr_vrf_assign_req *
>(from_req);
1678 key.set_var_vif_index(orig_req->get_var_vif_index());
1679 key.set_var_vlan_id(orig_req->get_var_marker());
1691 KSyncSockTypeMap::ksync_vrf_assign_tree::const_iterator it;
1692 static vr_vrf_assign_req req, *r, key;
1694 r =
static_cast<vr_vrf_assign_req *
>(input);
1696 key.set_var_vif_index(r->get_var_vif_index());
1697 key.set_var_vlan_id(r->get_var_vlan_id());
1709 KSyncSockTypeMap::ksync_map_vrf_stats::const_iterator it;
1710 static vr_vrf_stats_req req;
1722 KSyncSockTypeMap::ksync_map_vrf_stats::const_iterator it;
1723 static vr_vrf_stats_req req;
1725 vr_vrf_stats_req *orig_req;
1726 orig_req =
static_cast<vr_vrf_stats_req *
>(from_req);
1728 idx = orig_req->get_vsr_marker();
1740 KSyncSockTypeMap::ksync_map_vrf_stats::const_iterator it;
1741 static vr_vrf_stats_req req, *r;
1743 r =
static_cast<vr_vrf_stats_req *
>(input);
1755 KSyncSockTypeMap::ksync_map_vxlan::const_iterator it;
1756 static vr_vxlan_req req;
1768 KSyncSockTypeMap::ksync_map_vxlan::const_iterator it;
1769 static vr_vxlan_req req;
1770 vr_vxlan_req *orig_req;
1771 orig_req =
static_cast<vr_vxlan_req *
>(from_req);
1774 idx = orig_req->get_vxlanr_vnid();
1786 KSyncSockTypeMap::ksync_map_vxlan::const_iterator it;
1787 static vr_vxlan_req req, *r;
1789 r =
static_cast<vr_vxlan_req *
>(input);
1790 it = sock->
vxlan_map.upper_bound(r->get_vxlanr_vnid());
void SetBlockMsgProcessing(bool enable)
virtual uint32_t GetSeqno(char *data)
virtual Sandesh * GetFirst(Sandesh *)
static int GetNetlinkFamilyId()
static void VrfStatsDelete(int vrf_id)
static KSyncSockTypeMap * GetKSyncSockTypeMap()
void ProcessSandesh(const uint8_t *, std::size_t, KSyncUserSockContext *)
virtual void RouteMsgHandler(vr_route_req *req)
virtual Sandesh * GetFirst(Sandesh *)
static void SetUnderlaySourcePort(int idx, int port)
vr_drop_stats_req drop_stats
static int IoVectorToData(char *data, uint32_t len, KSyncBufferList *iovec)
virtual Sandesh * GetNext(Sandesh *)
void SendGetResponse(uint32_t seq_num, int idx)
static vr_flow_entry * GetFlowEntry(int idx)
virtual std::size_t SendTo(KSyncBufferList *iovec, uint32_t seq_no)
ksync_map_mirror mirror_map
virtual int32_t WriteBinary(u_int8_t *buf, u_int32_t buf_len, int *error)
virtual void VrfMsgHandler(vr_vrf_req *req)
virtual bool BulkDecoder(char *data, KSyncBulkSandeshContext *ctxt)
static void SetFlowTcpFlags(int idx, uint16_t flags)
boost::asio::ip::address IpAddress
static void IfStatsUpdate(int, int, int, int, int, int, int)
virtual Sandesh * Get(int idx)
virtual void Receive(boost::asio::mutable_buffers_1)
virtual Sandesh * GetNext(Sandesh *)
virtual Sandesh * Get(int idx)
bool IsBlockMsgProcessing()
ksync_map_vrf_stats vrf_stats_map
virtual Sandesh * GetFirst(Sandesh *)
static void SetDropStats(const vr_drop_stats_req &req)
std::vector< boost::asio::mutable_buffers_1 > KSyncBufferList
virtual Sandesh * GetFirst(Sandesh *)
virtual Sandesh * GetFirst(Sandesh *)
virtual void DropStatsMsgHandler(vr_drop_stats_req *req)
void AddNetlinkTxBuff(struct nl_client *cl)
virtual Sandesh * GetNext(Sandesh *)
vr_bridge_entry * GetBridgeEntry(int idx)
static void SetVRouterOps(const vrouter_ops &req)
static void FlowMmapFree()
static void VxlanAdd(int id)
virtual Sandesh * GetFirst(Sandesh *)
static void NetlinkBulkDecoder(char *data, SandeshContext *ctxt, bool more)
tbb::mutex ctx_queue_lock_
virtual Sandesh * GetFirst(Sandesh *)
static void ResetEvictedFlag(int idx)
virtual Sandesh * Get(int idx)
static void MplsDelete(int id)
ksync_map_vxlan vxlan_map
virtual void IfMsgHandler(vr_interface_req *req)
ksync_vrf_assign_tree vrf_assign_tree
static void MirrorAdd(int id)
virtual void VrfStatsMsgHandler(vr_vrf_stats_req *req)
static void InterfaceDelete(int id)
static void VrfStatsAdd(int vrf_id)
static void SetSockTableEntry(KSyncSock *sock)
static void VrfAssignAdd(vr_vrf_assign_req &req)
static void MirrorDelete(int id)
virtual Sandesh * GetNext(Sandesh *)
int EncodeVrResponse(uint8_t *buf, int buf_len, uint32_t seq_num, int code)
boost::function< void(const boost::system::error_code &, size_t)> HandlerCb
virtual Sandesh * GetNext(Sandesh *)
int GetKSyncError(KSyncSockEntryType type)
static void SetTcpFlag(int idx, uint32_t flags)
bool is_incremental_index()
virtual Sandesh * GetNext(Sandesh *)
static void Init(bool use_work_queue, const std::string &cpu_pin_policy)
void UpdateBridgeEntryInactiveFlag(int idx, bool set)
vr_bridge_entry * BridgeMmapAlloc(int size)
virtual void VxLanMsgHandler(vr_vxlan_req *req)
static void IfStatsSet(int, int, int, int, int, int, int)
static int32_t ReceiveBinaryMsgOne(u_int8_t *buf, u_int32_t buf_len, int *error, SandeshContext *client_context)
virtual Sandesh * GetNext(Sandesh *)
static void FlowNatResponse(uint32_t seq_num, vr_flow_req *req, int code=0)
static void Init(boost::asio::io_context &ios)
virtual bool Validate(char *data)
static void RouteDelete(vr_route_req &req)
virtual void FlowMsgHandler(vr_flow_req *req)
virtual void QosConfigMsgHandler(vr_qos_map_req *req)
virtual bool Decoder(char *data, AgentSandeshContext *ctxt)
virtual void VrfAssignMsgHandler(vr_vrf_assign_req *req)
virtual Sandesh * GetFirst(Sandesh *)
virtual Sandesh * Get(int idx)
virtual Sandesh * GetNext(Sandesh *)
static void InterfaceAdd(int id, int flags=0, int mac_size=6)
static void NHDelete(int id)
static void NHAdd(int id, int flags=0)
static void NetlinkDecoder(char *data, SandeshContext *ctxt)
void SendDumpResponse(uint32_t seq_num, Sandesh *)
static KSyncSockTypeMap * singleton_
static void MplsAdd(int id)
static void SetFlowEntry(vr_flow_req *req, bool set)
virtual Sandesh * GetFirst(Sandesh *)
virtual bool IsMoreData(char *data)
virtual Sandesh * GetNext(Sandesh *)
static void VrfAssignDelete(vr_vrf_assign_req &req)
void InitNetlinkDoneMsg(struct nlmsghdr *nlh, uint32_t seq_num)
virtual void ForwardingClassMsgHandler(vr_fc_map_req *req)
virtual void NHMsgHandler(vr_nexthop_req *req)
#define LOG(_Level, _Msg)
static vr_flow_entry * FlowMmapAlloc(int size)
void SetBridgeEntry(uint32_t idx, vr_route_req *req, bool set)
static void VrfStatsUpdate(int vrf_id, const vr_vrf_stats_req &req)
virtual Sandesh * Get(int idx)
static void VxlanDelete(int id)
void U64ToIp(uint64_t sip_u, uint64_t sip_l, uint64_t dip_u, uint64_t dip_l, int family, IpAddress *sip, IpAddress *dip)
virtual void MirrorMsgHandler(vr_mirror_req *req)
virtual void MplsMsgHandler(vr_mpls_req *req)
static void IncrFlowStats(int idx, int pkts, int bytes)
static vr_flow_entry * flow_table_
void DisableReceiveQueue(bool disable)
virtual void AsyncReceive(boost::asio::mutable_buffers_1, HandlerCb)
static void RouteAdd(vr_route_req &req)
static void SetEvictedFlag(int idx)
vrouter_ops ksync_vrouter_ops
virtual void AsyncSendTo(KSyncBufferList *iovec, uint32_t seq_no, HandlerCb cb)
static void SimulateResponse(uint32_t, int, int)
virtual Sandesh * Get(int idx)
virtual void VrouterOpsMsgHandler(vrouter_ops *req)
virtual Sandesh * Get(int idx)
ksync_map_ctx_queue ctx_queue_
static void SetOFlowStats(int idx, uint8_t pkts, uint16_t bytes)