Commit 123c69f2 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Move calls to kernel_setup_interface to network_up.

parent 2fbebc73
......@@ -347,13 +347,6 @@ main(int argc, char **argv)
goto fail;
}
rc = kernel_setup_interface(1, *arg, ifindex);
if(rc < 0) {
fprintf(stderr, "kernel_setup_interface(%s, %d) failed.\n",
*arg, ifindex);
goto fail;
}
mtu = kernel_interface_mtu(*arg, ifindex);
if(mtu < 0) {
fprintf(stderr, "Warning: couldn't get MTU of interface %s (%d).\n",
......@@ -604,7 +597,6 @@ main(int argc, char **argv)
flushbuf(&nets[i]);
usleep(50000 + random() % 100000);
network_up(&nets[i], 0);
kernel_setup_interface(0, nets[i].ifname, nets[i].ifindex);
}
kernel_setup_socket(0);
kernel_setup(0);
......@@ -653,7 +645,6 @@ main(int argc, char **argv)
if(!nets[i].up)
continue;
network_up(&nets[i], 0);
kernel_setup_interface(0, nets[i].ifname, nets[i].ifindex);
}
kernel_setup_socket(0);
kernel_setup(0);
......
......@@ -127,7 +127,7 @@ update_jitter(struct network *net, int urgent)
return (interval / 2 + random() % interval);
}
static int
int
network_up(struct network *net, int up)
{
int mtu, rc, wired;
......@@ -145,6 +145,13 @@ network_up(struct network *net, int up)
return network_up(net, 0);
}
rc = kernel_setup_interface(1, net->ifname, net->ifindex);
if(rc < 0) {
fprintf(stderr, "kernel_setup_interface(%s, %d) failed.\n",
net->ifname, net->ifindex);
return network_up(net, 0);
}
mtu = kernel_interface_mtu(net->ifname, net->ifindex);
if(mtu < 0) {
fprintf(stderr, "Warning: couldn't get MTU of interface %s (%d).\n",
......@@ -207,6 +214,7 @@ network_up(struct network *net, int up)
if(rc < 0) {
perror("setsockopt(IPV6_LEAVE_GROUP)");
}
kernel_setup_interface(0, net->ifname, net->ifindex);
}
}
......@@ -223,25 +231,6 @@ check_networks(void)
unsigned char ipv4[4];
for(i = 0; i < numnets; i++) {
rc = kernel_interface_ipv4(nets[i].ifname, nets[i].ifindex, ipv4);
if(rc > 0) {
if(!nets[i].ipv4 || memcmp(ipv4, nets[i].ipv4, 4) != 0) {
debugf("Noticed IPv4 change for %s.\n", nets[i].ifname);
if(!nets[i].ipv4)
nets[i].ipv4 = malloc(4);
if(nets[i].ipv4)
memcpy(nets[i].ipv4, ipv4, 4);
changed = 1;
}
} else {
debugf("Noticed IPv4 change for %s.\n", nets[i].ifname);
if(nets[i].ipv4) {
free(nets[i].ipv4);
nets[i].ipv4 = NULL;
changed = 1;
}
}
ifindex = if_nametoindex(nets[i].ifname);
if(ifindex != nets[i].ifindex) {
debugf("Noticed ifindex change for %s.\n", nets[i].ifname);
......
......@@ -52,4 +52,5 @@ int network_idle(struct network *net);
int update_hello_interval(struct network *net);
unsigned int jitter(struct network *net);
unsigned int update_jitter(struct network *net, int urgent);
int network_up(struct network *net, int up);
void check_networks(void);
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