diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2016-03-31 15:08:53 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2016-03-31 15:08:53 +0300 |
commit | b5c9c15c6ce2bb9cd34c31576703a4732f12c147 (patch) | |
tree | 17e84f1326cbde9c7689a2d8c265f282f841018f /accel-pppd | |
parent | 152940fa7dc9bed56ad66dd6e0f10df3ff2f9aac (diff) | |
download | accel-ppp-b5c9c15c6ce2bb9cd34c31576703a4732f12c147.tar.gz accel-ppp-b5c9c15c6ce2bb9cd34c31576703a4732f12c147.zip |
vlan_mon: clean state on start
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/vlan-mon/vlan_mon.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/accel-pppd/vlan-mon/vlan_mon.c b/accel-pppd/vlan-mon/vlan_mon.c index b7e71296..5dcd0fd3 100644 --- a/accel-pppd/vlan-mon/vlan_mon.c +++ b/accel-pppd/vlan-mon/vlan_mon.c @@ -169,6 +169,34 @@ int __export vlan_mon_del(int ifindex, int proto) return r; } +void vlan_mon_clean() +{ + struct rtnl_handle rth; + struct nlmsghdr *nlh; + struct genlmsghdr *ghdr; + struct { + struct nlmsghdr n; + char buf[1024]; + } req; + + if (rtnl_open_byproto(&rth, 0, NETLINK_GENERIC)) + return; + + nlh = &req.n; + nlh->nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN); + nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; + nlh->nlmsg_type = vlan_mon_genl_id; + + ghdr = NLMSG_DATA(&req.n); + ghdr->cmd = VLAN_MON_CMD_DEL; + + addattr32(nlh, 1024, VLAN_MON_ATTR_IFINDEX, -1); + + rtnl_talk(&rth, nlh, 0, 0, nlh, NULL, NULL, 0); + + rtnl_close(&rth); +} + static void vlan_mon_handler(const struct sockaddr_nl *addr, struct nlmsghdr *h) { struct rtattr *tb[PKT_ATTR_MAX + 1]; @@ -419,6 +447,8 @@ static void init(void) return; } + vlan_mon_clean(); + fcntl(rth.fd, F_SETFL, O_NONBLOCK); fcntl(rth.fd, F_SETFD, fcntl(rth.fd, F_GETFD) | FD_CLOEXEC); |