Commit 8138dfc2 authored by Grégoire Henry's avatar Grégoire Henry

Changement de signature pour kernel_route.

Ajout des parametres newgate et newifindex.
parent 54347c5d
......@@ -580,8 +580,9 @@ kernel_interface_wireless(const char *ifname, int ifindex)
int
kernel_route(int operation, const unsigned char *dest, unsigned short plen,
const unsigned char *gate, int ifindex,
unsigned int metric, unsigned int newmetric)
const unsigned char *gate, int ifindex, unsigned int metric,
const unsigned char *newgate, int newifindex,
unsigned int newmetric)
{
union { char raw[1024]; struct nlmsghdr nh; } buf;
......@@ -591,12 +592,15 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
int rc;
if(operation == ROUTE_MODIFY) {
if(newmetric == metric)
if(newmetric == metric && memcmp(newgate, gate, 16) == 0 &&
newifindex == ifindex)
return 0;
rc = kernel_route(ROUTE_ADD, dest, plen, gate, ifindex, newmetric, 0);
rc = kernel_route(ROUTE_ADD, dest, plen, newgate, newifindex, newmetric,
NULL, 0, 0);
if(rc < 0 && errno != EEXIST)
return rc;
rc = kernel_route(ROUTE_FLUSH, dest, plen, gate, ifindex, metric, 0);
rc = kernel_route(ROUTE_FLUSH, dest, plen, gate, ifindex, metric,
NULL, 0, 0);
if(rc < 0 && (errno == ENOENT || errno == ESRCH))
rc = 1;
return rc;
......
......@@ -39,7 +39,8 @@ int kernel_setup_interface(int setup, const char *ifname, int ifindex);
int kernel_interface_mtu(const char *ifname, int ifindex);
int kernel_interface_wireless(const char *ifname, int ifindex);
int kernel_route(int operation, const unsigned char *dest, unsigned short plen,
const unsigned char *gate, int ifindex,
unsigned int metric, unsigned int newmetric);
const unsigned char *gate, int ifindex, unsigned int metric,
const unsigned char *newgate, int newifindex,
unsigned int newmetric);
int kernel_routes(int maxplen, struct kernel_route *routes, int maxroutes);
int kernel_callback(int (*fn)(void*), void *closure);
......@@ -130,7 +130,7 @@ install_route(struct route *route)
rc = kernel_route(ROUTE_ADD, route->src->prefix, route->src->plen,
route->nexthop->address,
route->nexthop->network->ifindex,
metric_to_kernel(route->metric), 0);
metric_to_kernel(route->metric), NULL, 0, 0);
if(rc < 0) {
perror("kernel_route(ADD)");
if(errno != EEXIST)
......@@ -150,7 +150,7 @@ uninstall_route(struct route *route)
rc = kernel_route(ROUTE_FLUSH, route->src->prefix, route->src->plen,
route->nexthop->address,
route->nexthop->network->ifindex,
metric_to_kernel(route->metric), 0);
metric_to_kernel(route->metric), NULL, 0, 0);
if(rc < 0)
perror("kernel_route(FLUSH)");
......@@ -168,6 +168,8 @@ change_route_metric(struct route *route, int newmetric)
route->nexthop->address,
route->nexthop->network->ifindex,
metric_to_kernel(route->metric),
route->nexthop->address,
route->nexthop->network->ifindex,
metric_to_kernel(newmetric));
if(rc < 0) {
perror("kernel_route(MODIFY)");
......
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