summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2016-03-17 18:07:54 +0300
committerDmitry Kozlov <xeb@mail.ru>2016-03-17 18:07:54 +0300
commit9d6f83faa75d8f5091faaa6422420490692660d4 (patch)
treed8b2c557682d09a37d0773c5f7acdf2efa24cc8f /accel-pppd
parent1709f9496d5a47a45865df9c8328092aeb159bf7 (diff)
downloadaccel-ppp-9d6f83faa75d8f5091faaa6422420490692660d4.tar.gz
accel-ppp-9d6f83faa75d8f5091faaa6422420490692660d4.zip
ipoe: use local netlink socket in add/del interface functions (fix race condition)
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe_netlink.c14
1 files changed, 12 insertions, 2 deletions
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)