Allow routing table IDs > 255 when filtering them.
authorTobias Brunner <tobias@strongswan.org>
Fri, 29 Jul 2011 10:16:18 +0000 (12:16 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 29 Jul 2011 10:16:18 +0000 (12:16 +0200)
src/include/linux/rtnetlink.h
src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c

index 131822c..56835d8 100644 (file)
@@ -263,6 +263,7 @@ enum rtattr_type_t
        RTA_CACHEINFO,
        RTA_SESSION,
        RTA_MP_ALGO,
+       RTA_TABLE,
        __RTA_MAX
 };
 
index 9161be7..9d67a60 100644 (file)
@@ -904,7 +904,7 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
                                struct rtattr *rta;
                                size_t rtasize;
                                chunk_t rta_gtw, rta_src, rta_dst;
-                               u_int32_t rta_oif = 0;
+                               u_int32_t rta_oif = 0, rta_table;
                                host_t *new_src, *new_gtw;
                                bool cont = FALSE;
                                uintptr_t table;
@@ -913,6 +913,7 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
                                msg = (struct rtmsg*)(NLMSG_DATA(current));
                                rta = RTM_RTA(msg);
                                rtasize = RTM_PAYLOAD(current);
+                               rta_table = msg->rtm_table;
                                while (RTA_OK(rta, rtasize))
                                {
                                        switch (rta->rta_type)
@@ -932,6 +933,12 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
                                                                rta_oif = *(u_int32_t*)RTA_DATA(rta);
                                                        }
                                                        break;
+                                               case RTA_TABLE:
+                                                       if (RTA_PAYLOAD(rta) == sizeof(rta_table))
+                                                       {
+                                                               rta_table = *(u_int32_t*)RTA_DATA(rta);
+                                                       }
+                                                       break;
                                        }
                                        rta = RTA_NEXT(rta, rtasize);
                                }
@@ -942,7 +949,7 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
                                enumerator = this->rt_exclude->create_enumerator(this->rt_exclude);
                                while (enumerator->enumerate(enumerator, &table))
                                {
-                                       if (table == msg->rtm_table)
+                                       if (table == rta_table)
                                        {
                                                cont = TRUE;
                                                break;
@@ -954,7 +961,7 @@ static host_t *get_route(private_kernel_netlink_net_t *this, host_t *dest,
                                        continue;
                                }
                                if (this->routing_table != 0 &&
-                                       msg->rtm_table == this->routing_table)
+                                       rta_table == this->routing_table)
                                {       /* route is from our own ipsec routing table */
                                        continue;
                                }