diff options
| author | Michael Biebl <biebl@debian.org> | 2022-10-18 11:57:57 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2022-10-18 11:57:57 +0200 |
| commit | ac9380934a9c532c14422ee15b4869b2d5da14af (patch) | |
| tree | b5d020e8e72a2f3129c9ab0b311fd18c2a54918e /src/libnm-platform/nm-netlink.c | |
| parent | 87f7575d7268053774dacffc4bdd45df3f26b30b (diff) | |
| parent | 9f101839d9e64df832e9e43c5181887369c46a7e (diff) | |
Update upstream source from tag 'upstream/1.40.2'
Update to upstream version '1.40.2' with Debian dir 1072992b4531d6c782ca5c453f83a2df3ad6390a
Diffstat (limited to 'src/libnm-platform/nm-netlink.c')
| -rw-r--r-- | src/libnm-platform/nm-netlink.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/libnm-platform/nm-netlink.c b/src/libnm-platform/nm-netlink.c index 36841d56..e08eee5e 100644 --- a/src/libnm-platform/nm-netlink.c +++ b/src/libnm-platform/nm-netlink.c @@ -364,11 +364,22 @@ nla_reserve(struct nl_msg *msg, int attrtype, int attrlen) /*****************************************************************************/ +/** + * Allocate a new netlink message. + * + * Allocates a new netlink message without any further payload. If @len is zero, + * the maximum payload size is set to the size of one memory page. + * + * @return Newly allocated netlink message or NULL. + */ struct nl_msg * -nlmsg_alloc_size(size_t len) +nlmsg_alloc(size_t len) { struct nl_msg *nm; + if (len == 0) + len = nm_utils_getpagesize(); + if (len < sizeof(struct nlmsghdr)) len = sizeof(struct nlmsghdr); else if (len > UINT32_MAX) @@ -384,38 +395,23 @@ nlmsg_alloc_size(size_t len) return nm; } -/** - * Allocate a new netlink message with the default maximum payload size. - * - * Allocates a new netlink message without any further payload. The - * maximum payload size defaults to PAGESIZE or as otherwise specified - * with nlmsg_set_default_size(). - * - * @return Newly allocated netlink message or NULL. - */ -struct nl_msg * -nlmsg_alloc(void) -{ - return nlmsg_alloc_size(nm_utils_getpagesize()); -} - struct nl_msg * nlmsg_alloc_convert(struct nlmsghdr *hdr) { struct nl_msg *nm; - nm = nlmsg_alloc_size(NLMSG_ALIGN(hdr->nlmsg_len)); + nm = nlmsg_alloc(NLMSG_ALIGN(hdr->nlmsg_len)); memcpy(nm->nm_nlh, hdr, hdr->nlmsg_len); return nm; } struct nl_msg * -nlmsg_alloc_simple(uint16_t nlmsgtype, uint16_t flags) +nlmsg_alloc_new(size_t size, uint16_t nlmsgtype, uint16_t flags) { struct nl_msg *nm; struct nlmsghdr *new; - nm = nlmsg_alloc(); + nm = nlmsg_alloc(size); new = nm->nm_nlh; new->nlmsg_type = nlmsgtype; new->nlmsg_flags = flags; @@ -928,7 +924,7 @@ genl_ctrl_resolve(struct nl_sock *sk, const char *name) .valid_arg = &response_data, }; - msg = nlmsg_alloc(); + msg = nlmsg_alloc(0); if (!genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, GENL_ID_CTRL, 0, 0, CTRL_CMD_GETFAMILY, 1)) return -ENOMEM; |