Change nlmsg_len from sizeof(req) to use NLMSG_LENGTH on the header.
2 of the inner headers are not 4-byte aligned, so add a 0-length buf
after the header with the __aligned(NLMSG_ALIGNTO) to ensure the size
of the request is large enough. Use NLMSG_ALIGN in NLMSG_LENGTH to set
nlmsg_len.
Signed-off-by: David Ahern <dsahern@gmail.com>
+#define __aligned(x) __attribute__((aligned(x)))
+
#ifndef SOL_NETLINK
#define SOL_NETLINK 270
#endif
#ifndef SOL_NETLINK
#define SOL_NETLINK 270
#endif
struct nlmsghdr nlh;
struct ifaddrmsg ifm;
} req = {
struct nlmsghdr nlh;
struct ifaddrmsg ifm;
} req = {
- .nlh.nlmsg_len = sizeof(req),
+ .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)),
.nlh.nlmsg_type = RTM_GETADDR,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
.nlh.nlmsg_type = RTM_GETADDR,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
struct nlmsghdr nlh;
struct ifaddrlblmsg ifal;
} req = {
struct nlmsghdr nlh;
struct ifaddrlblmsg ifal;
} req = {
- .nlh.nlmsg_len = sizeof(req),
+ .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrlblmsg)),
.nlh.nlmsg_type = RTM_GETADDRLABEL,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
.nlh.nlmsg_type = RTM_GETADDRLABEL,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
struct nlmsghdr nlh;
struct rtmsg rtm;
} req = {
struct nlmsghdr nlh;
struct rtmsg rtm;
} req = {
- .nlh.nlmsg_len = sizeof(req),
+ .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)),
.nlh.nlmsg_type = RTM_GETROUTE,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
.nlh.nlmsg_type = RTM_GETROUTE,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
struct nlmsghdr nlh;
struct fib_rule_hdr frh;
} req = {
struct nlmsghdr nlh;
struct fib_rule_hdr frh;
} req = {
- .nlh.nlmsg_len = sizeof(req),
+ .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct fib_rule_hdr)),
.nlh.nlmsg_type = RTM_GETRULE,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
.nlh.nlmsg_type = RTM_GETRULE,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
struct nlmsghdr nlh;
struct ndmsg ndm;
} req = {
struct nlmsghdr nlh;
struct ndmsg ndm;
} req = {
- .nlh.nlmsg_len = sizeof(req),
+ .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg)),
.nlh.nlmsg_type = RTM_GETNEIGH,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
.nlh.nlmsg_type = RTM_GETNEIGH,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
struct nlmsghdr nlh;
struct ndtmsg ndtmsg;
} req = {
struct nlmsghdr nlh;
struct ndtmsg ndtmsg;
} req = {
- .nlh.nlmsg_len = sizeof(req),
+ .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndtmsg)),
.nlh.nlmsg_type = RTM_GETNEIGHTBL,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
.nlh.nlmsg_type = RTM_GETNEIGHTBL,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
struct nlmsghdr nlh;
struct br_port_msg bpm;
} req = {
struct nlmsghdr nlh;
struct br_port_msg bpm;
} req = {
- .nlh.nlmsg_len = sizeof(req),
+ .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct br_port_msg)),
.nlh.nlmsg_type = RTM_GETMDB,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
.nlh.nlmsg_type = RTM_GETMDB,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
struct {
struct nlmsghdr nlh;
struct netconfmsg ncm;
struct {
struct nlmsghdr nlh;
struct netconfmsg ncm;
+ char buf[0] __aligned(NLMSG_ALIGNTO);
- .nlh.nlmsg_len = sizeof(req),
+ .nlh.nlmsg_len = NLMSG_LENGTH(NLMSG_ALIGN(sizeof(struct netconfmsg))),
.nlh.nlmsg_type = RTM_GETNETCONF,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
.nlh.nlmsg_type = RTM_GETNETCONF,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
struct {
struct nlmsghdr nlh;
struct rtgenmsg rtm;
struct {
struct nlmsghdr nlh;
struct rtgenmsg rtm;
+ char buf[0] __aligned(NLMSG_ALIGNTO);
- .nlh.nlmsg_len = sizeof(req),
+ .nlh.nlmsg_len = NLMSG_LENGTH(NLMSG_ALIGN(sizeof(struct rtgenmsg))),
.nlh.nlmsg_type = RTM_GETNSID,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
.nlh.nlmsg_type = RTM_GETNSID,
.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
.nlh.nlmsg_seq = rth->dump = ++rth->seq,
struct nlmsghdr nlh;
struct ifinfomsg ifm;
/* attribute has to be NLMSG aligned */
struct nlmsghdr nlh;
struct ifinfomsg ifm;
/* attribute has to be NLMSG aligned */
- struct rtattr ext_req __attribute__ ((aligned(NLMSG_ALIGNTO)));
+ struct rtattr ext_req __aligned(NLMSG_ALIGNTO);
__u32 ext_filter_mask;
} req = {
.nlh.nlmsg_len = sizeof(req),
__u32 ext_filter_mask;
} req = {
.nlh.nlmsg_len = sizeof(req),