From: Felix Fietkau Date: Sun, 7 Feb 2016 19:46:03 +0000 (+0100) Subject: fix attribute alignment for rules X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=033df370f7e719d60bb52c50f83f679366a847f7;p=project%2Frelayd.git fix attribute alignment for rules Signed-off-by: Felix Fietkau --- diff --git a/route.c b/route.c index 6cea299..053ae97 100644 --- a/route.c +++ b/route.c @@ -27,6 +27,9 @@ #include "relayd.h" +#define NLMSG_ALIGNTO 4U +#define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) ) + static struct uloop_fd rtnl_sock; static unsigned int rtnl_seq, rtnl_dump_seq; int route_table = 16800; @@ -98,10 +101,11 @@ rtnl_rule_request(struct relayd_interface *rif, int flags) ifname = rif->ifname; if (!(flags & RULE_F_DEFGW_WORKAROUND)) { + int len = strlen(ifname) + 1; req.dev.rta.rta_type = FRA_IFNAME; - padding -= strlen(ifname) + 1; + padding -= NLMSG_ALIGN(len); strcpy(req.dev.ifname, ifname); - req.dev.rta.rta_len = sizeof(req.dev.rta) + strlen(ifname) + 1; + req.dev.rta.rta_len = sizeof(req.dev.rta) + len; } else { padding = sizeof(req.dev); req.prio.prio--;