@@ -174,15 +174,15 @@ ucs_netlink_send_request(int protocol, unsigned short nlmsg_type,
174174
175175static ucs_status_t
176176ucs_netlink_get_route_info (const struct rtattr * rta , int len , int * if_index_p ,
177- const void * * dst_in_addr )
177+ const void * * dst_in_addr , unsigned char rtm_dst_len )
178178{
179179 * if_index_p = -1 ;
180180 * dst_in_addr = NULL ;
181181
182182 for (; RTA_OK (rta , len ); rta = RTA_NEXT (rta , len )) {
183183 if (rta -> rta_type == RTA_OIF ) {
184184 * if_index_p = * ((const int * )RTA_DATA (rta ));
185- } else if (rta -> rta_type == RTA_DST ) {
185+ } else if (( rta -> rta_type == RTA_DST ) || ( rta -> rta_type == RTA_GATEWAY ) ) {
186186 * dst_in_addr = RTA_DATA (rta );
187187 }
188188 }
@@ -206,7 +206,8 @@ ucs_netlink_parse_rt_entry_cb(const struct nlmsghdr *nlh, void *arg)
206206 int khret ;
207207
208208 if (ucs_netlink_get_route_info (RTM_RTA (rt_msg ), RTM_PAYLOAD (nlh ),
209- & iface_index , & dst_in_addr ) != UCS_OK ) {
209+ & iface_index , & dst_in_addr ,
210+ rt_msg -> rtm_dst_len ) != UCS_OK ) {
210211 return UCS_INPROGRESS ;
211212 }
212213
@@ -228,15 +229,17 @@ ucs_netlink_parse_rt_entry_cb(const struct nlmsghdr *nlh, void *arg)
228229 ucs_error ("could not allocate route entry" );
229230 return UCS_ERR_NO_MEMORY );
230231
231- memset (& new_rule -> dest , 0 , sizeof (sizeof ( new_rule -> dest ) ));
232+ memset (& new_rule -> dest , 0 , sizeof (new_rule -> dest ));
232233 new_rule -> dest .ss_family = rt_msg -> rtm_family ;
233- if (UCS_OK != ucs_sockaddr_set_inet_addr ((struct sockaddr * )& new_rule -> dest ,
234- dst_in_addr )) {
235- ucs_array_pop_back (iface_rules );
236- return UCS_ERR_IO_ERROR ;
237- }
234+ if (rt_msg -> rtm_dst_len != 0 ) {
235+ if (ucs_sockaddr_set_inet_addr ((struct sockaddr * )& new_rule -> dest ,
236+ dst_in_addr ) != UCS_OK ) {
237+ ucs_array_pop_back (iface_rules );
238+ return UCS_ERR_IO_ERROR ;
239+ }
238240
239- new_rule -> subnet_prefix_len = rt_msg -> rtm_dst_len ;
241+ new_rule -> subnet_prefix_len = rt_msg -> rtm_dst_len ;
242+ }
240243
241244 return UCS_INPROGRESS ;
242245}
@@ -256,7 +259,8 @@ static void ucs_netlink_lookup_route(ucs_netlink_route_info_t *info)
256259
257260 iface_rules = & kh_val (& ucs_netlink_routing_table_cache , iter );
258261 ucs_array_for_each (curr_entry , iface_rules ) {
259- if (ucs_sockaddr_is_same_subnet (
262+ if ((curr_entry -> subnet_prefix_len == 0 ) ||
263+ ucs_sockaddr_is_same_subnet (
260264 info -> sa_remote ,
261265 (const struct sockaddr * )& curr_entry -> dest ,
262266 curr_entry -> subnet_prefix_len )) {
0 commit comments