linux-user,netlink: fix message translation with ip command
With iproute2-5.8.0, the route, link and addr show commands fail:
root@sid:~# ip addr show
RTNETLINK answers: Unknown error 352321537
Dump terminated
root@sid:~# ip link show
RTNETLINK answers: Unknown error 352321537
Dump terminated
root@sid:~# ip route show
RTNETLINK answers: Unknown error 352321537
Dump terminated
This patch correctly decodes the GETROUTE and GETLINK commands and adds
the RTA_TABLE message.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20201116163622.791442-1-laurent@vivier.eu>
diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c
index 1486c81..7551c88 100644
--- a/linux-user/fd-trans.c
+++ b/linux-user/fd-trans.c
@@ -1160,6 +1160,7 @@
break;
/* u32 */
case QEMU_RTA_PRIORITY:
+ case QEMU_RTA_TABLE:
case QEMU_RTA_OIF:
u32 = RTA_DATA(rtattr);
*u32 = tswap32(*u32);
@@ -1200,11 +1201,10 @@
struct rtmsg *rtm;
switch (nlh->nlmsg_type) {
- case RTM_GETLINK:
- break;
case RTM_NEWLINK:
case RTM_DELLINK:
case RTM_SETLINK:
+ case RTM_GETLINK:
if (nlh->nlmsg_len >= NLMSG_LENGTH(sizeof(*ifi))) {
ifi = NLMSG_DATA(nlh);
ifi->ifi_type = tswap16(ifi->ifi_type);
@@ -1225,10 +1225,9 @@
NLMSG_LENGTH(sizeof(*ifa)));
}
break;
- case RTM_GETROUTE:
- break;
case RTM_NEWROUTE:
case RTM_DELROUTE:
+ case RTM_GETROUTE:
if (nlh->nlmsg_len >= NLMSG_LENGTH(sizeof(*rtm))) {
rtm = NLMSG_DATA(nlh);
rtm->rtm_flags = tswap32(rtm->rtm_flags);