diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-01-19 14:21:17 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-01-19 14:21:17 +0400 |
commit | 0e6b9096f185632935f2a0800d9f340d7b61e9c4 (patch) | |
tree | ab02f8fbe0eb48170c28264c82e3862a734bdaa0 | |
parent | 42b8eaa35951e5381a7963d6bded7fa28b9b1713 (diff) | |
download | accel-ppp-0e6b9096f185632935f2a0800d9f340d7b61e9c4.tar.gz accel-ppp-0e6b9096f185632935f2a0800d9f340d7b61e9c4.zip |
increase size of buffer for netlink messages
Signed-off-by: Dmitry Kozlov <xeb@mail.ru>
-rw-r--r-- | accel-pppd/libnetlink/ipset.c | 18 | ||||
-rw-r--r-- | accel-pppd/libnetlink/iputils.c | 60 | ||||
-rw-r--r-- | accel-pppd/shaper/limiter.c | 26 |
3 files changed, 52 insertions, 52 deletions
diff --git a/accel-pppd/libnetlink/ipset.c b/accel-pppd/libnetlink/ipset.c index 24f72a11..73125352 100644 --- a/accel-pppd/libnetlink/ipset.c +++ b/accel-pppd/libnetlink/ipset.c @@ -32,7 +32,7 @@ static int __ipset_cmd(const char *name, in_addr_t addr, int cmd, int flags) struct req { struct nlmsghdr n; struct nfgenmsg nf; - char buf[1024]; + char buf[4096]; } req; struct rtattr *tail1, *tail2; uint8_t protocol = IPSET_PROTOCOL; @@ -42,7 +42,7 @@ static int __ipset_cmd(const char *name, in_addr_t addr, int cmd, int flags) return -1; } - memset(&req, 0, sizeof(req) - 1024); + memset(&req, 0, sizeof(req) - 4096); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct nfgenmsg)); req.n.nlmsg_flags = flags; @@ -51,13 +51,13 @@ static int __ipset_cmd(const char *name, in_addr_t addr, int cmd, int flags) req.nf.version = NFNETLINK_V0; req.nf.res_id = 0; - addattr_l(&req.n, 1024, IPSET_ATTR_PROTOCOL, &protocol, 1); - addattr_l(&req.n, 1024, IPSET_ATTR_SETNAME, name, strlen(name) + 1); + addattr_l(&req.n, 4096, IPSET_ATTR_PROTOCOL, &protocol, 1); + addattr_l(&req.n, 4096, IPSET_ATTR_SETNAME, name, strlen(name) + 1); tail1 = addattr_nest(&req.n, MAX_MSG, IPSET_ATTR_DATA | NLA_F_NESTED); tail2 = addattr_nest(&req.n, MAX_MSG, IPSET_ATTR_IP | NLA_F_NESTED); - addattr32(&req.n, 1024, IPSET_ATTR_IPADDR_IPV4 | NLA_F_NET_BYTEORDER, addr); + addattr32(&req.n, 4096, IPSET_ATTR_IPADDR_IPV4 | NLA_F_NET_BYTEORDER, addr); addattr_nest_end(&req.n, tail2); addattr_nest_end(&req.n, tail1); @@ -92,7 +92,7 @@ int __export ipset_flush(const char *name) struct req { struct nlmsghdr n; struct nfgenmsg nf; - char buf[1024]; + char buf[4096]; } req; uint8_t protocol = IPSET_PROTOCOL; @@ -101,7 +101,7 @@ int __export ipset_flush(const char *name) return -1; } - memset(&req, 0, sizeof(req) - 1024); + memset(&req, 0, sizeof(req) - 4096); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct nfgenmsg)); req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; @@ -110,8 +110,8 @@ int __export ipset_flush(const char *name) req.nf.version = NFNETLINK_V0; req.nf.res_id = 0; - addattr_l(&req.n, 1024, IPSET_ATTR_PROTOCOL, &protocol, 1); - addattr_l(&req.n, 1024, IPSET_ATTR_SETNAME, name, strlen(name) + 1); + addattr_l(&req.n, 4096, IPSET_ATTR_PROTOCOL, &protocol, 1); + addattr_l(&req.n, 4096, IPSET_ATTR_SETNAME, name, strlen(name) + 1); if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL, 0) < 0) goto out_err; diff --git a/accel-pppd/libnetlink/iputils.c b/accel-pppd/libnetlink/iputils.c index 1bbe76ba..fbb32c60 100644 --- a/accel-pppd/libnetlink/iputils.c +++ b/accel-pppd/libnetlink/iputils.c @@ -119,7 +119,7 @@ int __export iplink_get_stats(int ifindex, struct rtnl_link_stats *stats) struct iplink_req { struct nlmsghdr n; struct ifinfomsg i; - char buf[1024]; + char buf[4096]; } req; struct ifinfomsg *ifi; int len; @@ -131,7 +131,7 @@ int __export iplink_get_stats(int ifindex, struct rtnl_link_stats *stats) if (!rth) return -1; - memset(&req, 0, sizeof(req) - 1024); + memset(&req, 0, sizeof(req) - 4096); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; @@ -167,7 +167,7 @@ int __export iplink_vlan_add(const char *ifname, int ifindex, int vid) struct iplink_req { struct nlmsghdr n; struct ifinfomsg i; - char buf[1024]; + char buf[4096]; } req; struct rtattr *linkinfo, *data; @@ -177,23 +177,23 @@ int __export iplink_vlan_add(const char *ifname, int ifindex, int vid) if (!rth) return -1; - memset(&req, 0, sizeof(req) - 1024); + memset(&req, 0, sizeof(req) - 4096); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_CREATE | NLM_F_EXCL; req.n.nlmsg_type = RTM_NEWLINK; req.i.ifi_family = AF_UNSPEC; - addattr_l(&req.n, 1024, IFLA_LINK, &ifindex, 4); - addattr_l(&req.n, 1024, IFLA_IFNAME, ifname, strlen(ifname)); + addattr_l(&req.n, 4096, IFLA_LINK, &ifindex, 4); + addattr_l(&req.n, 4096, IFLA_IFNAME, ifname, strlen(ifname)); linkinfo = NLMSG_TAIL(&req.n); - addattr_l(&req.n, 1024, IFLA_LINKINFO, NULL, 0); - addattr_l(&req.n, 1024, IFLA_INFO_KIND, "vlan", 4); + addattr_l(&req.n, 4096, IFLA_LINKINFO, NULL, 0); + addattr_l(&req.n, 4096, IFLA_INFO_KIND, "vlan", 4); data = NLMSG_TAIL(&req.n); - addattr_l(&req.n, 1024, IFLA_INFO_DATA, NULL, 0); - addattr_l(&req.n, 1024, IFLA_VLAN_ID, &vid, 2); + addattr_l(&req.n, 4096, IFLA_INFO_DATA, NULL, 0); + addattr_l(&req.n, 4096, IFLA_VLAN_ID, &vid, 2); data->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)data; linkinfo->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)linkinfo; @@ -209,7 +209,7 @@ int __export iplink_vlan_del(int ifindex) struct iplink_req { struct nlmsghdr n; struct ifinfomsg i; - char buf[1024]; + char buf[4096]; } req; struct rtattr *linkinfo; @@ -219,7 +219,7 @@ int __export iplink_vlan_del(int ifindex) if (!rth) return -1; - memset(&req, 0, sizeof(req) - 1024); + memset(&req, 0, sizeof(req) - 4096); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; @@ -228,11 +228,11 @@ int __export iplink_vlan_del(int ifindex) req.i.ifi_index = ifindex; linkinfo = NLMSG_TAIL(&req.n); - addattr_l(&req.n, 1024, IFLA_LINKINFO, NULL, 0); - addattr_l(&req.n, 1024, IFLA_INFO_KIND, "vlan", 4); + addattr_l(&req.n, 4096, IFLA_LINKINFO, NULL, 0); + addattr_l(&req.n, 4096, IFLA_INFO_KIND, "vlan", 4); /*data = NLMSG_TAIL(&req.n); - addattr_l(&req.n, 1024, IFLA_VLAN_ID, &vid, 2); + addattr_l(&req.n, 4096, IFLA_VLAN_ID, &vid, 2); data->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)data;*/ linkinfo->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)linkinfo; @@ -248,7 +248,7 @@ int __export ipaddr_add(int ifindex, in_addr_t addr, int mask) struct ipaddr_req { struct nlmsghdr n; struct ifaddrmsg i; - char buf[1024]; + char buf[4096]; } req; if (!rth) @@ -257,7 +257,7 @@ int __export ipaddr_add(int ifindex, in_addr_t addr, int mask) if (!rth) return -1; - memset(&req, 0, sizeof(req) - 1024); + memset(&req, 0, sizeof(req) - 4096); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE; @@ -279,7 +279,7 @@ int __export ipaddr_del(int ifindex, in_addr_t addr) struct ipaddr_req { struct nlmsghdr n; struct ifaddrmsg i; - char buf[1024]; + char buf[4096]; } req; if (!rth) @@ -288,7 +288,7 @@ int __export ipaddr_del(int ifindex, in_addr_t addr) if (!rth) return -1; - memset(&req, 0, sizeof(req) - 1024); + memset(&req, 0, sizeof(req) - 4096); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); req.n.nlmsg_flags = NLM_F_REQUEST; @@ -310,7 +310,7 @@ int __export iproute_add(int ifindex, in_addr_t src, in_addr_t dst, int proto) struct ipaddr_req { struct nlmsghdr n; struct rtmsg i; - char buf[1024]; + char buf[4096]; } req; if (!rth) @@ -319,7 +319,7 @@ int __export iproute_add(int ifindex, in_addr_t src, in_addr_t dst, int proto) if (!rth) return -1; - memset(&req, 0, sizeof(req) - 1024); + memset(&req, 0, sizeof(req) - 4096); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE; @@ -347,7 +347,7 @@ int __export iproute_del(int ifindex, in_addr_t dst, int proto) struct ipaddr_req { struct nlmsghdr n; struct rtmsg i; - char buf[1024]; + char buf[4096]; } req; if (!rth) @@ -356,7 +356,7 @@ int __export iproute_del(int ifindex, in_addr_t dst, int proto) if (!rth) return -1; - memset(&req, 0, sizeof(req) - 1024); + memset(&req, 0, sizeof(req) - 4096); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; @@ -382,7 +382,7 @@ in_addr_t __export iproute_get(in_addr_t dst) struct ipaddr_req { struct nlmsghdr n; struct rtmsg r; - char buf[1024]; + char buf[4096]; } req; struct rtmsg *r; struct rtattr *tb[RTA_MAX+1]; @@ -395,7 +395,7 @@ in_addr_t __export iproute_get(in_addr_t dst) if (!rth) return -1; - memset(&req, 0, sizeof(req) - 1024); + memset(&req, 0, sizeof(req) - 4096); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); req.n.nlmsg_flags = NLM_F_REQUEST; @@ -409,7 +409,7 @@ in_addr_t __export iproute_get(in_addr_t dst) req.r.rtm_src_len = 0; req.r.rtm_dst_len = 32; - addattr32(&req.n, 1024, RTA_DST, dst); + addattr32(&req.n, 4096, RTA_DST, dst); if (rtnl_talk(rth, &req.n, 0, 0, &req.n, NULL, NULL, 0) < 0) { log_error("failed to detect route to server\n"); @@ -444,7 +444,7 @@ int __export iprule_add(uint32_t addr, int table) struct { struct nlmsghdr n; struct rtmsg i; - char buf[1024]; + char buf[4096]; } req; if (!rth) @@ -453,7 +453,7 @@ int __export iprule_add(uint32_t addr, int table) if (!rth) return -1; - memset(&req, 0, sizeof(req) - 1024); + memset(&req, 0, sizeof(req) - 4096); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); req.n.nlmsg_flags = NLM_F_REQUEST; @@ -480,7 +480,7 @@ int __export iprule_del(uint32_t addr, int table) struct ipaddr_req { struct nlmsghdr n; struct rtmsg i; - char buf[1024]; + char buf[4096]; } req; if (!rth) @@ -489,7 +489,7 @@ int __export iprule_del(uint32_t addr, int table) if (!rth) return -1; - memset(&req, 0, sizeof(req) - 1024); + memset(&req, 0, sizeof(req) - 4096); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); req.n.nlmsg_flags = NLM_F_REQUEST; diff --git a/accel-pppd/shaper/limiter.c b/accel-pppd/shaper/limiter.c index af1e3baa..a7ac49f0 100644 --- a/accel-pppd/shaper/limiter.c +++ b/accel-pppd/shaper/limiter.c @@ -41,9 +41,9 @@ static int qdisc_tbf(struct qdisc_opt *qopt, struct nlmsghdr *n) opt.buffer = tc_calc_xmittime(opt.rate.rate, qopt->buffer); tail = NLMSG_TAIL(n); - addattr_l(n, 1024, TCA_OPTIONS, NULL, 0); - addattr_l(n, 2024, TCA_TBF_PARMS, &opt, sizeof(opt)); - addattr_l(n, 3024, TCA_TBF_RTAB, rtab, 1024); + addattr_l(n, TCA_BUF_MAX, TCA_OPTIONS, NULL, 0); + addattr_l(n, TCA_BUF_MAX, TCA_TBF_PARMS, &opt, sizeof(opt)); + addattr_l(n, TCA_BUF_MAX, TCA_TBF_RTAB, rtab, 1024); tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; @@ -61,8 +61,8 @@ static int qdisc_htb_root(struct qdisc_opt *qopt, struct nlmsghdr *n) opt.defcls = qopt->defcls; tail = NLMSG_TAIL(n); - addattr_l(n, 1024, TCA_OPTIONS, NULL, 0); - addattr_l(n, 2024, TCA_HTB_INIT, &opt, NLMSG_ALIGN(sizeof(opt))); + addattr_l(n, TCA_BUF_MAX, TCA_OPTIONS, NULL, 0); + addattr_l(n, TCA_BUF_MAX, TCA_HTB_INIT, &opt, NLMSG_ALIGN(sizeof(opt))); tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; } @@ -96,10 +96,10 @@ static int qdisc_htb_class(struct qdisc_opt *qopt, struct nlmsghdr *n) opt.cbuffer = tc_calc_xmittime(opt.ceil.rate, conf_cburst ? conf_cburst : qopt->buffer); tail = NLMSG_TAIL(n); - addattr_l(n, 1024, TCA_OPTIONS, NULL, 0); - addattr_l(n, 2024, TCA_HTB_PARMS, &opt, sizeof(opt)); - addattr_l(n, 3024, TCA_HTB_RTAB, rtab, 1024); - addattr_l(n, 4024, TCA_HTB_CTAB, ctab, 1024); + addattr_l(n, TCA_BUF_MAX, TCA_OPTIONS, NULL, 0); + addattr_l(n, TCA_BUF_MAX, TCA_HTB_PARMS, &opt, sizeof(opt)); + addattr_l(n, TCA_BUF_MAX, TCA_HTB_RTAB, rtab, 1024); + addattr_l(n, TCA_BUF_MAX, TCA_HTB_CTAB, ctab, 1024); tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; } @@ -372,7 +372,7 @@ static int install_htb_ifb(struct rtnl_handle *rth, int ifindex, __u32 priority, tail1->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)tail1; // - addattr32(&req.n, 4096, TCA_U32_CLASSID, 1); + 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; @@ -534,9 +534,9 @@ int init_ifb(const char *name) addattr_l(&req.n, sizeof(req), TCA_KIND, "flow", 5); tail = NLMSG_TAIL(&req.n); - addattr_l(&req.n, 4096, TCA_OPTIONS, NULL, 0); - addattr32(&req.n, 4096, TCA_FLOW_KEYS, 1 << FLOW_KEY_PRIORITY); - addattr32(&req.n, 4096, TCA_FLOW_MODE, FLOW_MODE_MAP); + addattr_l(&req.n, TCA_BUF_MAX, TCA_OPTIONS, NULL, 0); + addattr32(&req.n, TCA_BUF_MAX, TCA_FLOW_KEYS, 1 << FLOW_KEY_PRIORITY); + addattr32(&req.n, TCA_BUF_MAX, TCA_FLOW_MODE, FLOW_MODE_MAP); tail->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)tail; r = rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL, 0); |