using netlink to get routes from a specific routing table
I am writing a program to print routes from a specific routing table. I am not using the main or local routing table. I add routes to a fixed table with a table id 7 (that I created). The routes get added to this newly added table. I can view it with "ip route show table 7". In my program I need to print this same output. When I use RTM_GETROUTE to get all entries for table=7, the kernel replies with entries that do not belong to table=7 as well. i.e. it returns entries belonging to main routing table.
This is what I saw on the man page of rtnetlink."For RTM_GETROUTE setting rtm_dst_len and rtm_src_len to 0 means you get all entries for the specified routing table. For the other fields except rtm_table and rtm_protocol 0 is the wildcard."
I have set rtm_table to 7 and I keep all other values 0. I haven't seen the kernel code properly, but I am assuming there must be a check on the kernel side to verify what table the getroute request is for.