Commit ffd18f72 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Check table before parsing kernel route.

parent 90aabddc
...@@ -629,8 +629,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen, ...@@ -629,8 +629,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
} }
static int static int
parse_kernel_route_rta(struct rtmsg *rtm, int len, parse_kernel_route_rta(struct rtmsg *rtm, int len, struct kernel_route *route)
struct kernel_route *route, int *table)
{ {
struct rtattr *rta= RTM_RTA(rtm);; struct rtattr *rta= RTM_RTA(rtm);;
...@@ -642,8 +641,6 @@ parse_kernel_route_rta(struct rtmsg *rtm, int len, ...@@ -642,8 +641,6 @@ parse_kernel_route_rta(struct rtmsg *rtm, int len,
route->metric = KERNEL_INFINITY; route->metric = KERNEL_INFINITY;
route->ifindex = 0; route->ifindex = 0;
*table = rtm->rtm_table;
while(RTA_OK(rta, len)) { while(RTA_OK(rta, len)) {
switch (rta->rta_type) { switch (rta->rta_type) {
case RTA_DST: case RTA_DST:
...@@ -705,7 +702,6 @@ monitor_kernel_route(struct nlmsghdr *nh, void *data) ...@@ -705,7 +702,6 @@ monitor_kernel_route(struct nlmsghdr *nh, void *data)
{ {
struct kernel_route route; struct kernel_route route;
int table;
int len = nh->nlmsg_len; int len = nh->nlmsg_len;
struct rtmsg *rtm; struct rtmsg *rtm;
...@@ -716,7 +712,7 @@ monitor_kernel_route(struct nlmsghdr *nh, void *data) ...@@ -716,7 +712,7 @@ monitor_kernel_route(struct nlmsghdr *nh, void *data)
rtm = (struct rtmsg*)NLMSG_DATA(nh); rtm = (struct rtmsg*)NLMSG_DATA(nh);
len -= NLMSG_LENGTH(0); len -= NLMSG_LENGTH(0);
parse_kernel_route_rta(rtm, len, &route, &table); parse_kernel_route_rta(rtm, len, &route);
print_kernel_route(nh->nlmsg_type, rtm->rtm_protocol, print_kernel_route(nh->nlmsg_type, rtm->rtm_protocol,
rtm->rtm_type, &route); rtm->rtm_type, &route);
return 0; return 0;
...@@ -733,7 +729,6 @@ filter_kernel_routes(struct nlmsghdr *nh, void *data) ...@@ -733,7 +729,6 @@ filter_kernel_routes(struct nlmsghdr *nh, void *data)
int *found = (int*)args[3]; int *found = (int*)args[3];
struct rtmsg *rtm; struct rtmsg *rtm;
int table;
int len = nh->nlmsg_len; int len = nh->nlmsg_len;
...@@ -755,12 +750,11 @@ filter_kernel_routes(struct nlmsghdr *nh, void *data) ...@@ -755,12 +750,11 @@ filter_kernel_routes(struct nlmsghdr *nh, void *data)
if(rtm->rtm_dst_len > maxplen || rtm->rtm_src_len != 0) if(rtm->rtm_dst_len > maxplen || rtm->rtm_src_len != 0)
return 0; return 0;
parse_kernel_route_rta(rtm, len, &routes[*found], &table); if(rtm->rtm_table != RT_TABLE_MAIN)
if(table != RT_TABLE_MAIN)
return 0; return 0;
//*found++; ?? parse_kernel_route_rta(rtm, len, &routes[*found]);
*found = (*found)+1; *found = (*found)+1;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment