summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2016-03-17 16:30:52 +0300
committerDmitry Kozlov <xeb@mail.ru>2016-03-17 16:30:52 +0300
commit61d91047cdbf134c98d414951d84e38ff2adbd34 (patch)
tree02c5b61e421964be092f2a56beed61b7f8e9feb0
parent3f4beaca9bcea35ffeff810f068487dd449cc2cb (diff)
downloadaccel-ppp-61d91047cdbf134c98d414951d84e38ff2adbd34.tar.gz
accel-ppp-61d91047cdbf134c98d414951d84e38ff2adbd34.zip
ipoe: fixed possible race condition
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 9d3890d5..30ee87f0 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -1826,6 +1826,7 @@ void ipoe_recv_up(int ifindex, struct ethhdr *eth, struct iphdr *iph)
struct ipoe_serv *serv;
struct ipoe_session *ses;
+ pthread_mutex_lock(&serv_lock);
list_for_each_entry(serv, &serv_list, entry) {
if (serv->ifindex != ifindex)
continue;
@@ -1846,6 +1847,7 @@ void ipoe_recv_up(int ifindex, struct ethhdr *eth, struct iphdr *iph)
break;
}
+ pthread_mutex_unlock(&serv_lock);
}
#ifdef RADIUS
@@ -2407,11 +2409,6 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
close(sock);
}
- if (opt_up)
- ipoe_nl_add_interface(ifindex, opt_mode);
- else
- ipoe_nl_add_interface(ifindex, 0);
-
pthread_mutex_lock(&serv_lock);
list_for_each_entry(serv, &serv_list, entry) {
if (strcmp(ifname, serv->ifname))
@@ -2477,6 +2474,11 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
}
pthread_mutex_unlock(&serv_lock);
+ if (opt_up)
+ ipoe_nl_add_interface(ifindex, opt_mode);
+ else
+ ipoe_nl_add_interface(ifindex, 0);
+
opt = strchr(opt, ',');
if (opt)
opt++;