for (i = 0; i < ips_nr; i++) {
union tcp_addr *p = (union tcp_addr *)&ips[i];
+ int err;
- if (ip_route_add(veth_name, TEST_FAMILY, this_ip_addr, *p))
+ err = ip_route_add(veth_name, TEST_FAMILY, this_ip_addr, *p);
+ if (err && err != -EEXIST)
test_error("Failed to add route");
}
}
req.nh.nlmsg_seq = seq;
req.rt.rtm_family = family;
req.rt.rtm_dst_len = (family == AF_INET) ? 32 : 128;
- req.rt.rtm_table = RT_TABLE_MAIN;
+ req.rt.rtm_table = vrf;
req.rt.rtm_protocol = RTPROT_BOOT;
req.rt.rtm_scope = RT_SCOPE_UNIVERSE;
req.rt.rtm_type = RTN_UNICAST;
ret = __ip_route_add(route_sock, route_seq++, intf,
family, src, dst, vrf);
- if (ret == -EEXIST) /* ignoring */
- ret = 0;
close(route_sock);
return ret;
err = ip_route_add_vrf(veth_name, TEST_FAMILY,
this_ip_addr, this_ip_dest, test_vrf_tabid);
if (err)
- test_error("Failed to add a route to VRF");
+ test_error("Failed to add a route to VRF: %d", err);
}
static void try_accept(const char *tst_name, unsigned int port,
static void client_add_ip(union tcp_addr *client, const char *ip)
{
- int family = TEST_FAMILY;
+ int err, family = TEST_FAMILY;
if (inet_pton(family, ip, client) != 1)
test_error("Can't convert ip address %s", ip);
- if (ip_addr_add(veth_name, family, *client, TEST_PREFIX))
- test_error("Failed to add ip address");
- if (ip_route_add(veth_name, family, *client, this_ip_dest))
- test_error("Failed to add route");
+ err = ip_addr_add(veth_name, family, *client, TEST_PREFIX);
+ if (err)
+ test_error("Failed to add ip address: %d", err);
}
static void client_add_ips(void)