From b5c9c15c6ce2bb9cd34c31576703a4732f12c147 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Thu, 31 Mar 2016 15:08:53 +0300 Subject: vlan_mon: clean state on start --- accel-pppd/vlan-mon/vlan_mon.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'accel-pppd/vlan-mon') diff --git a/accel-pppd/vlan-mon/vlan_mon.c b/accel-pppd/vlan-mon/vlan_mon.c index b7e7129..5dcd0fd 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); -- cgit v1.2.3