aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2020-11-18 20:05:05 +0900
committerKazuki Yamaguchi <k@rhe.jp>2020-11-18 20:05:05 +0900
commit51bf10ba1da1fd33df8cfdaaf44f5003707441a5 (patch)
tree5841ca6c1da27c4bcee120ff5e55ebc32a5d51bd
parent8478f5e265bb0ffa774641015a5c490701f8af09 (diff)
parent794ad99854c0484294410676d119622ed82fe7d4 (diff)
downloadbird-51bf10ba1da1fd33df8cfdaaf44f5003707441a5.tar.gz
Merge branch 'ky/netlink-static-tx-buffer-size' into master-2.0.7m
* ky/netlink-static-tx-buffer-size: Netlink: Allocate static sized buffer for netlink message
-rw-r--r--sysdep/linux/netlink.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c
index 1a4d69a0..5c848141 100644
--- a/sysdep/linux/netlink.c
+++ b/sysdep/linux/netlink.c
@@ -126,7 +126,8 @@ struct nl_sock
uint last_size;
};
-#define NL_RX_SIZE 8192
+#define NL_RX_SIZE 32768
+#define NL_TX_SIZE 8192
#define NL_OP_DELETE 0
#define NL_OP_ADD (NLM_F_CREATE|NLM_F_EXCL)
@@ -1205,15 +1206,6 @@ krt_capable(rte *e)
}
}
-static inline int
-nh_bufsize(struct nexthop *nh)
-{
- int rv = 0;
- for (; nh != NULL; nh = nh->next)
- rv += RTNH_LENGTH(RTA_LENGTH(sizeof(ip_addr)));
- return rv;
-}
-
static int
nl_send_route(struct krt_proto *p, rte *e, int op, int dest, struct nexthop *nh)
{
@@ -1221,17 +1213,15 @@ nl_send_route(struct krt_proto *p, rte *e, int op, int dest, struct nexthop *nh)
net *net = e->net;
rta *a = e->attrs;
ea_list *eattrs = a->eattrs;
- int bufsize = 128 + KRT_METRICS_MAX*8 + nh_bufsize(&(a->nh));
u32 priority = 0;
struct {
struct nlmsghdr h;
struct rtmsg r;
- char buf[0];
- } *r;
+ char buf[NL_TX_SIZE];
+ } _r, *r = &_r;
- int rsize = sizeof(*r) + bufsize;
- r = alloca(rsize);
+ int rsize = sizeof(_r);
DBG("nl_send_route(%N,op=%x)\n", net->n.addr, op);