diff --git a/src/vnsw/agent/gdb/agent_db.py b/src/vnsw/agent/gdb/agent_db.py index 87f488668ad..5cbbeae6026 100644 --- a/src/vnsw/agent/gdb/agent_db.py +++ b/src/vnsw/agent/gdb/agent_db.py @@ -2,7 +2,7 @@ # Copyright (c) 2016 Juniper Networks. All rights reserved. # # agent_db.py -# +# # gdb macros to dump the vrouter agent DB object/entries import gdb @@ -49,9 +49,153 @@ def print_db_entries(db_table, print_fn = print_db_entry): def print_vrf_entry(entry_ptr, entry): vrf = entry.cast(gdb.lookup_type('VrfEntry')) - print(str(entry_ptr) + " %-20s idx=%-4d ref_count=%-4d flags=%-4d rt_db=" % (vrf['name_']['_M_dataplus']['_M_p'], vrf['id_'], vrf['refcount_']['my_storage']['my_value'], vrf['flags']) + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::INET4_UNICAST'))]) + " mcrt_db=" + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::INET4_MULTICAST'))]) + " evpn_db=" + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::EVPN'))]) + " bridge_db=" + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::BRIDGE'))]) + " v6_rt_db=" + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::INET6_UNICAST'))])) + print(str(entry_ptr) + " %-20s idx=%-4d ref_count=%-4d flags=%-4d rt_db=" % ((vrf['name_']), vrf['id_'], vrf['refcount_']['my_storage']['my_value'], vrf['flags']) + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::INET4_UNICAST'))]) + " mcrt_db=" + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::INET4_MULTICAST'))]) + " evpn_db=" + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::EVPN'))]) + " bridge_db=" + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::BRIDGE'))]) + " v6_rt_db=" + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::INET6_UNICAST'))])) def dump_vrf_entries(): vrf_table = gdb.parse_and_eval('Agent::singleton_.vrf_table_') print_db_entries(vrf_table, print_vrf_entry) +def print_vn_entry(entry_ptr, entry): + vn = entry.cast(gdb.lookup_type('VnEntry')) + print(str(entry_ptr) + " %-20s" % (vn['name_'])) + +def dump_vn_entries(): + vn_table = gdb.parse_and_eval('Agent::singleton_.vn_table_') + print_db_entries(vn_table, print_vn_entry) + +def print_vm_entry(entry_ptr, entry): + vm = entry.cast(gdb.lookup_type('VmEntry')) + print(str(entry_ptr) + " %-20s" % (vm['name_'])) + +def dump_vm_entries(): + vm_table = gdb.parse_and_eval('Agent::singleton_.vm_table_') + print_db_entries(vm_table, print_vm_entry) + +def print_intf_entry(entry_ptr, entry): + Intf = entry.cast(gdb.lookup_type(str(entry.dynamic_type))) + print(str(entry_ptr) + " %-20s ref_count=%-4d flags=%-4d" % ((Intf['name_']), Intf['refcount_']['my_storage']['my_value'], Intf['flags'])) + +def dump_intf_entries(): + intf_table = gdb.parse_and_eval('Agent::singleton_.intf_table_') + print_db_entries(intf_table, print_intf_entry) + +def print_nh_entry(entry_ptr, entry): + nh = entry.cast(gdb.lookup_type(str(entry.dynamic_type))) + print (str(entry_ptr) + " type=%-4d flags=%-4d ref=%-4d valid=%-4d policy=%-4d\n" % (nh['type_'], nh['flags'], nh['refcount_']['my_storage']['my_value'], nh['valid_'], nh['policy_'])) + +def dump_nh_entries(): + nh_table = gdb.parse_and_eval('Agent::singleton_.nh_table_') + print_db_entries(nh_table, print_nh_entry) + +def print_mpls_entry(entry_ptr, entry): + mpls = entry.cast(gdb.lookup_type('MplsLabel')) + print(str(entry_ptr) + " label=%-4x nh=%d\n" % (mpls['label_'], mpls['nh_']['px'])) + +def dump_mpls_entries(): + mpls_table = gdb.parse_and_eval('Agent::singleton_.mpls_table_') + print_db_entries(mpls_table, print_mpls_entry) + +def print_vxlan_entry(entry_ptr, entry): + vxlan = entry.cast(gdb.lookup_type('VxLanId')) + print(str(entry_ptr) + " label=%-4x nh=%d\n" % (vxlan['vxlan_id_'], vxlan['nh_']['px'])) + +def dump_vxlan_entries(): + vxlan_table = gdb.parse_and_eval('Agent::singleton_.vxlan_table_') + print_db_entries(vxlan_table, print_vxlan_entry) + +def print_vrf_assign_entry(entry_ptr, entry): + vrf_assign = entry.cast(gdb.lookup_type('VrfAssign')) + print (str(entry_ptr) + " flags=%-4d ref=%-4d type=%-4d tag=%-4d\n" % (va['flags'], va['refcount_']['my_storage']['my_value'], va['type'], va['vlan_tag_'])) + +def dump_vrf_assign_entries(): + vrf_assign_table = gdb.parse_and_eval('Agent::singleton_.vrf_assign_table_') + print_db_entries(vrf_assign_table, print_vrf_assign_entry) + +def print_acl_entry(entry_ptr, entry): + acl = entry.cast(gdb.lookup_type('AclDBEntry')) + print (str(entry_ptr) + " %s ref=%d\n" % (acl['name_'], acl['refcount_']['my_storage']['my_value'])) + +def dump_acl_entries(): + acl_table = gdb.parse_and_eval('Agent::singleton_.acl_table_') + print_db_entries(acl_table, print_acl_entry) + +def print_sg_entry(entry_ptr, entry): + sg = entry.cast(gdb.lookup_type('SgEntry')) + print ( str(entry_ptr) + " %d engress_acl=%s ingress_acl=%s\n" % (sg['sg_id_'], sg['egress_acl_']['px'], sg['ingress_acl_']['px'])) + +def dump_sg_entries(): + sg_table = gdb.parse_and_eval('Agent::singleton_.sg_table_') + print_db_entries(sg_table, print_sg_entry) + +def print_uc_route_entry(entry_ptr, entry): + rt = entry.cast(gdb.lookup_type('InetUnicastRouteEntry')) + ip = rt['addr_']['ipv4_address_']['addr_']['s_addr'] + print ( str(entry_ptr) + " %d.%d.%d.%d/%d\t\t flags=%d\n" % ((ip & 0xff),\ + (ip >> 8 & 0xff), (ip >> 16 & 0xff),\ + (ip >> 24 & 0xff), rt['plen_'], rt['flags'])) + +def print_mc_route_entry(entry_ptr, entry): + rt = entry.cast(gdb.lookup_type(str(entry.dynamic_type))) + ip = rt['dst_addr_']['addr_']['s_addr'] + sip = rt['src_addr_']['addr_']['s_addr'] + print (str(entry_ptr) + " %d.%d.%d.%d/%d.%d.%d.%d\t\t flags=%d\n" % ((ip & 0xff),\ + (ip >> 8 & 0xff), (ip >> 16 & 0xff),\ + (ip >> 24 & 0xff), (sip & 0xff),\ + (sip >> 8 & 0xff), (sip >> 16 & 0xff),\ + (sip >> 24 & 0xff), rt['flags'])) + +def print_l2_route_entry(entry_ptr, entry): + rt = entry.cast(gdb.lookup_type('BridgeRouteEntry')) + mac = rt['mac_']['addr_'] + print( str(entry_ptr) + " %02x:%02x:%02x:%02x:%02x:%02x\t\t flags=%d\n" % \ + ( (mac['ether_addr_octet'][0]), (mac['ether_addr_octet'][1]),\ + (mac['ether_addr_octet'][2]), (mac['ether_addr_octet'][3]),\ + (mac['ether_addr_octet'][4]), (mac['ether_addr_octet'][5]),\ + rt['flags'])) + +def print_route_entry(entry_ptr, entry): + path = entry.cast(gdb.lookup_type('AgentPath')) + print ( "Path : %s Peer : %s NH : %s Label : %s\n" % (str(entry_ptr) , path['peer'], path['nh_']['px'], path['label_'])) + +def dump_uc_v4_route_entries(table): + uc_v4_route_table = gdb.parse_and_eval(str(table)) + print_db_entries(uc_v4_route_table, print_uc_route_entry) + +def dump_mc_v4_route_entries(table): + mc_v4_route_table = gdb.parse_and_eval(str(table)) + print_db_entries(mc_v4_route_table, print_mc_route_entry) + +def dump_l2_route_entries(table): + l2_route_table = gdb.parse_and_eval(str(table)) + print_db_entries(l2_route_table, print_l2_route_entry) + +def print_ifmap_node_entry(entry_ptr, entry): + ifnode = entry.cast(gdb.lookup_type('IFMapNode')) + print (str(entry_ptr) + " name=%-40s\n" % str(ifnode['name_'])) + +def dump_ifmap_entries(table): + ifmap_table = gdb.parse_and_eval(str(table)) + print_db_entries(ifmap_table, print_ifmap_node_entry) + +def print_iflink_entry(entry_ptr, entry): + iflink = entry.cast(gdb.lookup_type('IFMapLink')) + left = iflink['node_']['left_node_'] + print ("Left %s name=%-40s - " % str(left), left['name_']) + right = iflink['node_']['right_node_'] + print ("Right %s name=%-40s\n" % str(right), right['name_']) + +def dump_ifmap_link_entries(table): + ifmap_table = gdb.parse_and_eval(str(table)) + print_db_entries(ifmap_table, print_iflink_entry) + +def print_service_instance_entry(entry_ptr, entry): + svi = entry.cast(gdb.lookup_type('ServiceInstance')) + prop = svi['properties_'] + print (str(entry_ptr) + " Uuid:%-20s ServiceType:%s VirtualisationType:%s VmiInside:%-20s VmiOutside:%-20s MacIn:%s MacOut:%s IpIn:%s IpOut:%s IpLenIn:%s IpLenOut:%s IfCount:%s LbPool:%-20s" % ( + prop['instance_id']['data'], prop['service_type'], prop['virtualization_type'], prop['vmi_inside']['data'], prop['vmi_outside']['data'], prop['mac_addr_inside'], prop['mac_addr_outside'], + prop['ip_addr_inside'], prop['ip_addr_outside'], prop['ip_prefix_len_inside'], prop['ip_prefix_len_outside'], prop['interface_count'], prop['loadbalancer_id']['data'])) + +def dump_service_instance_entries(table): + svi_table = gdb.parse_and_eval(str(table)) + print_db_entries(svi_table, print_service_instance_entry) + diff --git a/src/vnsw/agent/gdb/agent_ksync.py b/src/vnsw/agent/gdb/agent_ksync.py index 902c2155e3f..4fdf958f535 100644 --- a/src/vnsw/agent/gdb/agent_ksync.py +++ b/src/vnsw/agent/gdb/agent_ksync.py @@ -38,3 +38,70 @@ def dump_nh_ksync_entries(): nh_table = gdb.parse_and_eval('Agent::singleton_->ksync_->nh_ksync_obj_.px') print_ksync_entries(nh_table, print_nh_ksync_entry) +def print_mpls_ksync_entry(entry_ptr, entry): + kmpls = entry.cast(gdb.lookup_type(str(entry.dynamic_type))) + print (str(entry_ptr) + " label=%-5s nh=%-5s " % (kmpls['label_'], kmpls['nh_'])) + +def dump_ksync_mpls_entries(): + kmpls_table = gdb.parse_and_eval('Agent::singleton_->ksync_->mpls_ksync_obj_.px') + print_ksync_entries(kmpls_table, print_mpls_ksync_entry) + +def print_kintf_entry(entry_ptr, entry): + kintf = entry.cast(gdb.lookup_type('InterfaceKSyncEntry')) + print(str(entry_ptr) + " idx=%-5d name=%-20s " % (kintf['index_'],\ + kintf['interface_name_']['_M_dataplus']['_M_p'])) +def dump_ksync_intf_entries(): + kintf_table = gdb.parse_and_eval('Agent::singleton_->ksync_->interface_ksync_obj_.px') + print_ksync_entries(kintf_table, print_kintf_entry) + +def print_kvrf_assign_entries(entry_ptr, entry): + kvrf_assign = entry.cast(gdb.lookup_type('VrfAssignKSyncEntry')) + print (str(entry_ptr) + " id=%-5s vlan_tag=%-5s nh=%-5s " % (kvrf_assign['vrf_id_'], kvrf_assign['vlan_tag_'], kvrf_assign['nh_'])) + +def dump_kvrf_assign_entries(): + kvrf_assign_table = gdb.parse_and_eval('Agent::singleton_->ksync_->vrf_assign_ksync_obj_.px') + print_ksync_entries(kvrf_assign_table, print_kvrf_assign_entries) + +def print_ksync_route_entry(entry_ptr, ptr): + krt = entry.cast(gdb.lookup_type('RouteKSyncEntry')) + ip = krt['addr_']['ipv4_address_']['addr_']['s_addr'] + print (str(entry_ptr) + " %d.%d.%d.%d/%d vrf=%d label=%d nh=%d " % ((ip & 0xff),\ + (ip >> 8 & 0xff), (ip >> 16 & 0xff), (ip >> 24 & 0xff),\ + krt['plen_'], krt['vrf_id_'], krt['label_'], krt['nh_']['px'])) + +def dump_ksync_route_entries(table): + ksync_uc_route_table = gdb.parse_and_eval(str(table)) + print_ksync_entries(ksync_uc_route_table, print_ksync_route_entry) + +def dump_ksync_mc_route_entries(table): + ksync_mc_route_table = gdb.parse_and_eval(str(table)) + print_ksync_entries(ksync_mc_route_table, print_ksync_route_entry) + +def print_ksync_flow_entry(entry_ptr, entry): + flow = entry.cast(gdb.lookup_type('FlowTableKSyncEntry')) + print ( str(entry_ptr) + " hash=0x%-8x fp=%s \n" % (kflow['hash_id_'], kflow['flow_entry_']['px'])) + +def dump_ksync_flow_entries(table): + pksync_entries = gdb.parse_and_eval(str(table)) + print_ksync_entries(pksync_entries, print_ksync_flow_entry) + +def print_ksync_mirror_entry(entry, entry_ptr): + kmirror_entry = entry.cast(gdb.lookup_type('MirrorKSyncEntry')) + sip = mirror['sip_']['addr_']['s_addr'] + dip = mirror['dip_']['addr_']['s_addr'] + print (str(entry_ptr) + " %d.%d.%d.%d:%d %d.%d.%d.%d:%d nh=%s\n" % ((sip >> 8 & 0xff), (sip >> 16 & 0xff),\ + (sip >> 24 & 0xff), mirror['sport_'],\ + (dip & 0xff), (dip >> 8 & 0xff), (dip >> 16 & 0xff),\ + (dip >> 24 & 0xff), mirror['dport_'], mirror['nh_']['px'] )) + +def dump_ksync_mirror_entries(): + mirror_entries = gdb.parse_and_eval('Agent::singleton_->ksync_->mirror_ksync_obj_.px') + print_ksync_entries(mirror_entries, print_ksync_mirror_entry) + +def dump_ksync_vxlan_entries(): + vxlan_entries = gdb.parse_and_eval('Agent::singleton_->ksync_->vxlan_ksync_obj_.px') + print_ksync_entries(vxlan_entries, print_ksync_vxlan_entry) + +def print_ksync_vxlan_entry(entry, entry_ptr): + kvxlan = entry.cast(gdb.lookup_type('VxLanIdKSyncEntry')) + print (str(entry_ptr) + " nh=%s label=%s\n" % (kvxlan['nh_']['px'], kvxlan['label_']))