aboutgitcodebugslistschat
path: root/netlink.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-02-23 10:50:09 +0100
committerStefano Brivio <sbrivio@redhat.com>2022-02-23 13:21:52 +0100
commited58ad1a5998291385d29dc9069f64af7a8f6dd1 (patch)
tree3ffc4da18cd8380b42292902c9daae3a6387502f /netlink.c
parent08b7a2ec3885191b125afcccec7f662fc1617156 (diff)
downloadpasst-ed58ad1a5998291385d29dc9069f64af7a8f6dd1.tar
passt-ed58ad1a5998291385d29dc9069f64af7a8f6dd1.tar.gz
passt-ed58ad1a5998291385d29dc9069f64af7a8f6dd1.tar.bz2
passt-ed58ad1a5998291385d29dc9069f64af7a8f6dd1.tar.lz
passt-ed58ad1a5998291385d29dc9069f64af7a8f6dd1.tar.xz
passt-ed58ad1a5998291385d29dc9069f64af7a8f6dd1.tar.zst
passt-ed58ad1a5998291385d29dc9069f64af7a8f6dd1.zip
netlink: Avoid left-over bytes in request on MTU configuration
When nl_link() configures the MTU, it shouldn't send extra bytes, otherwise we'll get a kernel warning: netlink: 4 bytes leftover after parsing attributes in process `pasta'. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'netlink.c')
-rw-r--r--netlink.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/netlink.c b/netlink.c
index 532868d..a530f3f 100644
--- a/netlink.c
+++ b/netlink.c
@@ -479,13 +479,16 @@ next:
void nl_link(int ns, unsigned int ifi, void *mac, int up, int mtu)
{
int change = !MAC_IS_ZERO(mac) || up || mtu;
- struct {
+ struct req_t {
struct nlmsghdr nlh;
struct ifinfomsg ifm;
struct rtattr rta;
union {
unsigned char mac[ETH_ALEN];
- unsigned int mtu;
+ struct {
+ unsigned int mtu;
+ uint8_t end;
+ } mtu;
} set;
} req = {
.nlh.nlmsg_type = change ? RTM_NEWLINK : RTM_GETLINK,
@@ -513,8 +516,8 @@ void nl_link(int ns, unsigned int ifi, void *mac, int up, int mtu)
}
if (mtu) {
- req.nlh.nlmsg_len = sizeof(req);
- req.set.mtu = mtu;
+ req.nlh.nlmsg_len = offsetof(struct req_t, set.mtu.end);
+ req.set.mtu.mtu = mtu;
req.rta.rta_type = IFLA_MTU;
req.rta.rta_len = RTA_LENGTH(sizeof(unsigned int));
nl_req(ns, buf, &req, req.nlh.nlmsg_len);