--- limiter.c_orig 2018-08-30 15:54:13.373216582 +0300 +++ limiter.c 2018-08-30 15:58:25.773303016 +0300 @@ -13,6 +13,7 @@ #include #include #include +#include #include "log.h" #include "ppp.h" @@ -326,6 +327,10 @@ .ifindex = conf_ifb_ifindex, }; + struct tc_gact p3 = { + .action = TC_ACT_OK, + }; + if (tc_qdisc_modify(rth, conf_ifb_ifindex, RTM_NEWTCLASS, NLM_F_EXCL|NLM_F_CREATE, &opt1)) return -1; @@ -342,7 +347,7 @@ req.t.tcm_handle = 1; req.t.tcm_parent = 0xffff0000; - req.t.tcm_info = TC_H_MAKE(100 << 16, ntohs(ETH_P_IP)); + req.t.tcm_info = TC_H_MAKE(100 << 16, ntohs(ETH_P_ALL)); addattr_l(&req.n, sizeof(req), TCA_KIND, "u32", 4); @@ -386,6 +391,50 @@ addattr32(&req.n, TCA_BUF_MAX, TCA_U32_CLASSID, 1); addattr_l(&req.n, MAX_MSG, TCA_U32_SEL, &sel, sizeof(sel)); + tail->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)tail; + + if (rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL, 0) < 0) + return -1; + + //Pass ARP + memset(&req, 0, sizeof(req)); + + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)); + req.n.nlmsg_flags = NLM_F_REQUEST|NLM_F_EXCL|NLM_F_CREATE; + req.n.nlmsg_type = RTM_NEWTFILTER; + req.t.tcm_family = AF_UNSPEC; + req.t.tcm_ifindex = ifindex; + req.t.tcm_handle = 1; + req.t.tcm_parent = 0xffff0000; + + req.t.tcm_info = TC_H_MAKE(90 << 16, ntohs(ETH_P_ARP)); + + + addattr_l(&req.n, sizeof(req), TCA_KIND, "u32", 4); + + tail = NLMSG_TAIL(&req.n); + addattr_l(&req.n, MAX_MSG, TCA_OPTIONS, NULL, 0); + + tail1 = NLMSG_TAIL(&req.n); + addattr_l(&req.n, MAX_MSG, TCA_U32_ACT, NULL, 0); + + // action pass + tail2 = NLMSG_TAIL(&req.n); + addattr_l(&req.n, MAX_MSG, 1, NULL, 0); + addattr_l(&req.n, MAX_MSG, TCA_ACT_KIND, "gact", 5); + + tail3 = NLMSG_TAIL(&req.n); + addattr_l(&req.n, MAX_MSG, TCA_ACT_OPTIONS, NULL, 0); + addattr_l(&req.n, MAX_MSG, TCA_GACT_PARMS, &p3, sizeof(p3)); + tail3->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)tail3; + + tail2->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)tail2; + + tail1->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)tail1; + // + + addattr32(&req.n, TCA_BUF_MAX, TCA_U32_CLASSID, 1); + addattr_l(&req.n, MAX_MSG, TCA_U32_SEL, &sel, sizeof(sel)); tail->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)tail; if (rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL, 0) < 0)