qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] linux-user,netlink: fix message translation with ip command
@ 2020-11-16 16:36 Laurent Vivier
  2020-11-17 14:20 ` Laurent Vivier
  0 siblings, 1 reply; 2+ messages in thread
From: Laurent Vivier @ 2020-11-16 16:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier

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>
---
 linux-user/fd-trans.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c
index 1486c81aaa27..7551c883304a 100644
--- a/linux-user/fd-trans.c
+++ b/linux-user/fd-trans.c
@@ -1160,6 +1160,7 @@ static abi_long target_to_host_data_route_rtattr(struct rtattr *rtattr)
         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 @@ static abi_long target_to_host_data_route(struct nlmsghdr *nlh)
     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 @@ static abi_long target_to_host_data_route(struct nlmsghdr *nlh)
                                        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);
-- 
2.28.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] linux-user,netlink: fix message translation with ip command
  2020-11-16 16:36 [PATCH] linux-user,netlink: fix message translation with ip command Laurent Vivier
@ 2020-11-17 14:20 ` Laurent Vivier
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Vivier @ 2020-11-17 14:20 UTC (permalink / raw)
  To: qemu-devel

Le 16/11/2020 à 17:36, Laurent Vivier a écrit :
> 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>
> ---
>  linux-user/fd-trans.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c
> index 1486c81aaa27..7551c883304a 100644
> --- a/linux-user/fd-trans.c
> +++ b/linux-user/fd-trans.c
> @@ -1160,6 +1160,7 @@ static abi_long target_to_host_data_route_rtattr(struct rtattr *rtattr)
>          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 @@ static abi_long target_to_host_data_route(struct nlmsghdr *nlh)
>      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 @@ static abi_long target_to_host_data_route(struct nlmsghdr *nlh)
>                                         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);
> 

Applied to my linux-user-for-5.2 branch.

Thanks,
Laurent




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-17 14:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-16 16:36 [PATCH] linux-user,netlink: fix message translation with ip command Laurent Vivier
2020-11-17 14:20 ` Laurent Vivier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).