diff options
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 24 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe_netlink.c | 14 |
2 files changed, 29 insertions, 9 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 68841fef..c986c63b 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -1826,17 +1826,21 @@ 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; - if (!serv->opt_up) + if (!serv->opt_up) { + pthread_mutex_unlock(&serv_lock); return; + } pthread_mutex_lock(&serv->lock); list_for_each_entry(ses, &serv->sessions, entry) { if (ses->yiaddr == iph->saddr) { pthread_mutex_unlock(&serv->lock); + pthread_mutex_unlock(&serv_lock); return; } } @@ -1846,6 +1850,7 @@ void ipoe_recv_up(int ifindex, struct ethhdr *eth, struct iphdr *iph) break; } + pthread_mutex_unlock(&serv_lock); } #ifdef RADIUS @@ -2299,9 +2304,14 @@ void ipoe_vlan_mon_notify(int ifindex, int vid, int vlan_ifindex) continue; add_interface(ifname, ifr.ifr_ifindex, opt->val, ifindex, vid); - } else if (ptr - opt->val == len && memcmp(opt->val, ifname, len) == 0) + return; + } else if (ptr - opt->val == len && memcmp(opt->val, ifname, len) == 0) { add_interface(ifname, ifr.ifr_ifindex, opt->val, ifindex, vid); + return; + } } + + log_warn("ipoe: vlan %s not started\n", ifname); } static void ipoe_serv_timeout(struct triton_timer_t *t) @@ -2438,11 +2448,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)) @@ -2508,6 +2513,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++; diff --git a/accel-pppd/ctrl/ipoe/ipoe_netlink.c b/accel-pppd/ctrl/ipoe/ipoe_netlink.c index cd2433e9..7e61fb84 100644 --- a/accel-pppd/ctrl/ipoe/ipoe_netlink.c +++ b/accel-pppd/ctrl/ipoe/ipoe_netlink.c @@ -100,6 +100,7 @@ void ipoe_nl_del_exclude(uint32_t addr) void ipoe_nl_add_interface(int ifindex, uint8_t mode) { + struct rtnl_handle rth; struct nlmsghdr *nlh; struct genlmsghdr *ghdr; struct { @@ -107,8 +108,10 @@ void ipoe_nl_add_interface(int ifindex, uint8_t mode) char buf[1024]; } req; - if (rth.fd == -1) + if (rtnl_open_byproto(&rth, 0, NETLINK_GENERIC)) { + log_ppp_error("ipoe: cannot open generic netlink socket\n"); return; + } nlh = &req.n; nlh->nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN); @@ -123,10 +126,13 @@ void ipoe_nl_add_interface(int ifindex, uint8_t mode) if (rtnl_talk(&rth, nlh, 0, 0, nlh, NULL, NULL, 0) < 0 ) log_error("ipoe: nl_add_iface: error talking to kernel\n"); + + rtnl_close(&rth); } void ipoe_nl_del_interface(int ifindex) { + struct rtnl_handle rth; struct nlmsghdr *nlh; struct genlmsghdr *ghdr; struct { @@ -134,8 +140,10 @@ void ipoe_nl_del_interface(int ifindex) char buf[1024]; } req; - if (rth.fd == -1) + if (rtnl_open_byproto(&rth, 0, NETLINK_GENERIC)) { + log_ppp_error("ipoe: cannot open generic netlink socket\n"); return; + } nlh = &req.n; nlh->nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN); @@ -149,6 +157,8 @@ void ipoe_nl_del_interface(int ifindex) if (rtnl_talk(&rth, nlh, 0, 0, nlh, NULL, NULL, 0) < 0 ) log_error("ipoe: nl_del_iface: error talking to kernel\n"); + + rtnl_close(&rth); } void ipoe_nl_delete_interfaces(void) |