From 61d91047cdbf134c98d414951d84e38ff2adbd34 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Thu, 17 Mar 2016 16:30:52 +0300 Subject: ipoe: fixed possible race condition --- accel-pppd/ctrl/ipoe/ipoe.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'accel-pppd') 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++; -- cgit v1.2.3