2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 #include "qemu/osdep.h"
18 #include <sys/signalfd.h>
19 #include <linux/unistd.h>
20 #include <linux/audit.h>
22 #include <sys/inotify.h>
24 #include <linux/netlink.h>
25 #ifdef CONFIG_RTNETLINK
26 #include <linux/rtnetlink.h>
27 #include <linux/if_bridge.h>
34 QEMU_IFLA_BR_FORWARD_DELAY
,
35 QEMU_IFLA_BR_HELLO_TIME
,
37 QEMU_IFLA_BR_AGEING_TIME
,
38 QEMU_IFLA_BR_STP_STATE
,
39 QEMU_IFLA_BR_PRIORITY
,
40 QEMU_IFLA_BR_VLAN_FILTERING
,
41 QEMU_IFLA_BR_VLAN_PROTOCOL
,
42 QEMU_IFLA_BR_GROUP_FWD_MASK
,
44 QEMU_IFLA_BR_BRIDGE_ID
,
45 QEMU_IFLA_BR_ROOT_PORT
,
46 QEMU_IFLA_BR_ROOT_PATH_COST
,
47 QEMU_IFLA_BR_TOPOLOGY_CHANGE
,
48 QEMU_IFLA_BR_TOPOLOGY_CHANGE_DETECTED
,
49 QEMU_IFLA_BR_HELLO_TIMER
,
50 QEMU_IFLA_BR_TCN_TIMER
,
51 QEMU_IFLA_BR_TOPOLOGY_CHANGE_TIMER
,
52 QEMU_IFLA_BR_GC_TIMER
,
53 QEMU_IFLA_BR_GROUP_ADDR
,
54 QEMU_IFLA_BR_FDB_FLUSH
,
55 QEMU_IFLA_BR_MCAST_ROUTER
,
56 QEMU_IFLA_BR_MCAST_SNOOPING
,
57 QEMU_IFLA_BR_MCAST_QUERY_USE_IFADDR
,
58 QEMU_IFLA_BR_MCAST_QUERIER
,
59 QEMU_IFLA_BR_MCAST_HASH_ELASTICITY
,
60 QEMU_IFLA_BR_MCAST_HASH_MAX
,
61 QEMU_IFLA_BR_MCAST_LAST_MEMBER_CNT
,
62 QEMU_IFLA_BR_MCAST_STARTUP_QUERY_CNT
,
63 QEMU_IFLA_BR_MCAST_LAST_MEMBER_INTVL
,
64 QEMU_IFLA_BR_MCAST_MEMBERSHIP_INTVL
,
65 QEMU_IFLA_BR_MCAST_QUERIER_INTVL
,
66 QEMU_IFLA_BR_MCAST_QUERY_INTVL
,
67 QEMU_IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
,
68 QEMU_IFLA_BR_MCAST_STARTUP_QUERY_INTVL
,
69 QEMU_IFLA_BR_NF_CALL_IPTABLES
,
70 QEMU_IFLA_BR_NF_CALL_IP6TABLES
,
71 QEMU_IFLA_BR_NF_CALL_ARPTABLES
,
72 QEMU_IFLA_BR_VLAN_DEFAULT_PVID
,
74 QEMU_IFLA_BR_VLAN_STATS_ENABLED
,
75 QEMU_IFLA_BR_MCAST_STATS_ENABLED
,
76 QEMU_IFLA_BR_MCAST_IGMP_VERSION
,
77 QEMU_IFLA_BR_MCAST_MLD_VERSION
,
78 QEMU_IFLA_BR_VLAN_STATS_PER_PORT
,
79 QEMU_IFLA_BR_MULTI_BOOLOPT
,
103 QEMU_IFLA_NET_NS_PID
,
106 QEMU_IFLA_VFINFO_LIST
,
114 QEMU_IFLA_PROMISCUITY
,
115 QEMU_IFLA_NUM_TX_QUEUES
,
116 QEMU_IFLA_NUM_RX_QUEUES
,
118 QEMU_IFLA_PHYS_PORT_ID
,
119 QEMU_IFLA_CARRIER_CHANGES
,
120 QEMU_IFLA_PHYS_SWITCH_ID
,
121 QEMU_IFLA_LINK_NETNSID
,
122 QEMU_IFLA_PHYS_PORT_NAME
,
123 QEMU_IFLA_PROTO_DOWN
,
124 QEMU_IFLA_GSO_MAX_SEGS
,
125 QEMU_IFLA_GSO_MAX_SIZE
,
129 QEMU_IFLA_NEW_NETNSID
,
130 QEMU_IFLA_IF_NETNSID
,
131 QEMU_IFLA_CARRIER_UP_COUNT
,
132 QEMU_IFLA_CARRIER_DOWN_COUNT
,
133 QEMU_IFLA_NEW_IFINDEX
,
137 QEMU_IFLA_ALT_IFNAME
,
138 QEMU_IFLA_PERM_ADDRESS
,
143 QEMU_IFLA_BRPORT_UNSPEC
,
144 QEMU_IFLA_BRPORT_STATE
,
145 QEMU_IFLA_BRPORT_PRIORITY
,
146 QEMU_IFLA_BRPORT_COST
,
147 QEMU_IFLA_BRPORT_MODE
,
148 QEMU_IFLA_BRPORT_GUARD
,
149 QEMU_IFLA_BRPORT_PROTECT
,
150 QEMU_IFLA_BRPORT_FAST_LEAVE
,
151 QEMU_IFLA_BRPORT_LEARNING
,
152 QEMU_IFLA_BRPORT_UNICAST_FLOOD
,
153 QEMU_IFLA_BRPORT_PROXYARP
,
154 QEMU_IFLA_BRPORT_LEARNING_SYNC
,
155 QEMU_IFLA_BRPORT_PROXYARP_WIFI
,
156 QEMU_IFLA_BRPORT_ROOT_ID
,
157 QEMU_IFLA_BRPORT_BRIDGE_ID
,
158 QEMU_IFLA_BRPORT_DESIGNATED_PORT
,
159 QEMU_IFLA_BRPORT_DESIGNATED_COST
,
162 QEMU_IFLA_BRPORT_TOPOLOGY_CHANGE_ACK
,
163 QEMU_IFLA_BRPORT_CONFIG_PENDING
,
164 QEMU_IFLA_BRPORT_MESSAGE_AGE_TIMER
,
165 QEMU_IFLA_BRPORT_FORWARD_DELAY_TIMER
,
166 QEMU_IFLA_BRPORT_HOLD_TIMER
,
167 QEMU_IFLA_BRPORT_FLUSH
,
168 QEMU_IFLA_BRPORT_MULTICAST_ROUTER
,
169 QEMU_IFLA_BRPORT_PAD
,
170 QEMU_IFLA_BRPORT_MCAST_FLOOD
,
171 QEMU_IFLA_BRPORT_MCAST_TO_UCAST
,
172 QEMU_IFLA_BRPORT_VLAN_TUNNEL
,
173 QEMU_IFLA_BRPORT_BCAST_FLOOD
,
174 QEMU_IFLA_BRPORT_GROUP_FWD_MASK
,
175 QEMU_IFLA_BRPORT_NEIGH_SUPPRESS
,
176 QEMU_IFLA_BRPORT_ISOLATED
,
177 QEMU_IFLA_BRPORT_BACKUP_PORT
,
178 QEMU_IFLA_BRPORT_MRP_RING_OPEN
,
179 QEMU_IFLA_BRPORT_MRP_IN_OPEN
,
180 QEMU___IFLA_BRPORT_MAX
184 QEMU_IFLA_TUN_UNSPEC
,
189 QEMU_IFLA_TUN_VNET_HDR
,
190 QEMU_IFLA_TUN_PERSIST
,
191 QEMU_IFLA_TUN_MULTI_QUEUE
,
192 QEMU_IFLA_TUN_NUM_QUEUES
,
193 QEMU_IFLA_TUN_NUM_DISABLED_QUEUES
,
198 QEMU_IFLA_INFO_UNSPEC
,
201 QEMU_IFLA_INFO_XSTATS
,
202 QEMU_IFLA_INFO_SLAVE_KIND
,
203 QEMU_IFLA_INFO_SLAVE_DATA
,
204 QEMU___IFLA_INFO_MAX
,
208 QEMU_IFLA_INET_UNSPEC
,
210 QEMU___IFLA_INET_MAX
,
214 QEMU_IFLA_INET6_UNSPEC
,
215 QEMU_IFLA_INET6_FLAGS
,
216 QEMU_IFLA_INET6_CONF
,
217 QEMU_IFLA_INET6_STATS
,
218 QEMU_IFLA_INET6_MCAST
,
219 QEMU_IFLA_INET6_CACHEINFO
,
220 QEMU_IFLA_INET6_ICMP6STATS
,
221 QEMU_IFLA_INET6_TOKEN
,
222 QEMU_IFLA_INET6_ADDR_GEN_MODE
,
223 QEMU___IFLA_INET6_MAX
227 QEMU_IFLA_XDP_UNSPEC
,
229 QEMU_IFLA_XDP_ATTACHED
,
231 QEMU_IFLA_XDP_PROG_ID
,
246 QEMU_RTA_PROTOINFO
, /* no longer used */
249 QEMU_RTA_SESSION
, /* no longer used */
250 QEMU_RTA_MP_ALGO
, /* no longer used */
262 QEMU_RTA_TTL_PROPAGATE
,
269 TargetFdTrans
**target_fd_trans
;
270 unsigned int target_fd_max
;
272 static void tswap_nlmsghdr(struct nlmsghdr
*nlh
)
274 nlh
->nlmsg_len
= tswap32(nlh
->nlmsg_len
);
275 nlh
->nlmsg_type
= tswap16(nlh
->nlmsg_type
);
276 nlh
->nlmsg_flags
= tswap16(nlh
->nlmsg_flags
);
277 nlh
->nlmsg_seq
= tswap32(nlh
->nlmsg_seq
);
278 nlh
->nlmsg_pid
= tswap32(nlh
->nlmsg_pid
);
281 static abi_long
host_to_target_for_each_nlmsg(struct nlmsghdr
*nlh
,
283 abi_long (*host_to_target_nlmsg
)
287 uint32_t aligned_nlmsg_len
;
290 while (len
> sizeof(struct nlmsghdr
)) {
292 nlmsg_len
= nlh
->nlmsg_len
;
293 if (nlmsg_len
< sizeof(struct nlmsghdr
) ||
298 switch (nlh
->nlmsg_type
) {
306 struct nlmsgerr
*e
= NLMSG_DATA(nlh
);
307 e
->error
= tswap32(e
->error
);
308 tswap_nlmsghdr(&e
->msg
);
313 ret
= host_to_target_nlmsg(nlh
);
322 aligned_nlmsg_len
= NLMSG_ALIGN(nlmsg_len
);
323 if (aligned_nlmsg_len
>= len
) {
326 len
-= aligned_nlmsg_len
;
327 nlh
= (struct nlmsghdr
*)(((char*)nlh
) + aligned_nlmsg_len
);
332 static abi_long
target_to_host_for_each_nlmsg(struct nlmsghdr
*nlh
,
334 abi_long (*target_to_host_nlmsg
)
337 uint32_t aligned_nlmsg_len
;
340 while (len
> sizeof(struct nlmsghdr
)) {
341 if (tswap32(nlh
->nlmsg_len
) < sizeof(struct nlmsghdr
) ||
342 tswap32(nlh
->nlmsg_len
) > len
) {
346 switch (nlh
->nlmsg_type
) {
353 struct nlmsgerr
*e
= NLMSG_DATA(nlh
);
354 e
->error
= tswap32(e
->error
);
355 tswap_nlmsghdr(&e
->msg
);
359 ret
= target_to_host_nlmsg(nlh
);
365 aligned_nlmsg_len
= NLMSG_ALIGN(nlh
->nlmsg_len
);
366 if (aligned_nlmsg_len
>= len
) {
369 len
-= aligned_nlmsg_len
;
370 nlh
= (struct nlmsghdr
*)(((char *)nlh
) + aligned_nlmsg_len
);
375 #ifdef CONFIG_RTNETLINK
376 static abi_long
host_to_target_for_each_nlattr(struct nlattr
*nlattr
,
377 size_t len
, void *context
,
378 abi_long (*host_to_target_nlattr
)
382 unsigned short nla_len
;
383 unsigned short aligned_nla_len
;
386 while (len
> sizeof(struct nlattr
)) {
387 nla_len
= nlattr
->nla_len
;
388 if (nla_len
< sizeof(struct nlattr
) ||
392 ret
= host_to_target_nlattr(nlattr
, context
);
393 nlattr
->nla_len
= tswap16(nlattr
->nla_len
);
394 nlattr
->nla_type
= tswap16(nlattr
->nla_type
);
399 aligned_nla_len
= NLA_ALIGN(nla_len
);
400 if (aligned_nla_len
>= len
) {
403 len
-= aligned_nla_len
;
404 nlattr
= (struct nlattr
*)(((char *)nlattr
) + aligned_nla_len
);
409 static abi_long
host_to_target_for_each_rtattr(struct rtattr
*rtattr
,
411 abi_long (*host_to_target_rtattr
)
414 unsigned short rta_len
;
415 unsigned short aligned_rta_len
;
418 while (len
> sizeof(struct rtattr
)) {
419 rta_len
= rtattr
->rta_len
;
420 if (rta_len
< sizeof(struct rtattr
) ||
424 ret
= host_to_target_rtattr(rtattr
);
425 rtattr
->rta_len
= tswap16(rtattr
->rta_len
);
426 rtattr
->rta_type
= tswap16(rtattr
->rta_type
);
431 aligned_rta_len
= RTA_ALIGN(rta_len
);
432 if (aligned_rta_len
>= len
) {
435 len
-= aligned_rta_len
;
436 rtattr
= (struct rtattr
*)(((char *)rtattr
) + aligned_rta_len
);
441 #define NLA_DATA(nla) ((void *)((char *)(nla)) + NLA_HDRLEN)
443 static abi_long
host_to_target_data_bridge_nlattr(struct nlattr
*nlattr
,
450 switch (nlattr
->nla_type
) {
452 case QEMU_IFLA_BR_FDB_FLUSH
:
455 case QEMU_IFLA_BR_GROUP_ADDR
:
458 case QEMU_IFLA_BR_VLAN_FILTERING
:
459 case QEMU_IFLA_BR_TOPOLOGY_CHANGE
:
460 case QEMU_IFLA_BR_TOPOLOGY_CHANGE_DETECTED
:
461 case QEMU_IFLA_BR_MCAST_ROUTER
:
462 case QEMU_IFLA_BR_MCAST_SNOOPING
:
463 case QEMU_IFLA_BR_MCAST_QUERY_USE_IFADDR
:
464 case QEMU_IFLA_BR_MCAST_QUERIER
:
465 case QEMU_IFLA_BR_NF_CALL_IPTABLES
:
466 case QEMU_IFLA_BR_NF_CALL_IP6TABLES
:
467 case QEMU_IFLA_BR_NF_CALL_ARPTABLES
:
468 case QEMU_IFLA_BR_VLAN_STATS_ENABLED
:
469 case QEMU_IFLA_BR_MCAST_STATS_ENABLED
:
470 case QEMU_IFLA_BR_MCAST_IGMP_VERSION
:
471 case QEMU_IFLA_BR_MCAST_MLD_VERSION
:
472 case QEMU_IFLA_BR_VLAN_STATS_PER_PORT
:
475 case QEMU_IFLA_BR_PRIORITY
:
476 case QEMU_IFLA_BR_VLAN_PROTOCOL
:
477 case QEMU_IFLA_BR_GROUP_FWD_MASK
:
478 case QEMU_IFLA_BR_ROOT_PORT
:
479 case QEMU_IFLA_BR_VLAN_DEFAULT_PVID
:
480 u16
= NLA_DATA(nlattr
);
481 *u16
= tswap16(*u16
);
484 case QEMU_IFLA_BR_FORWARD_DELAY
:
485 case QEMU_IFLA_BR_HELLO_TIME
:
486 case QEMU_IFLA_BR_MAX_AGE
:
487 case QEMU_IFLA_BR_AGEING_TIME
:
488 case QEMU_IFLA_BR_STP_STATE
:
489 case QEMU_IFLA_BR_ROOT_PATH_COST
:
490 case QEMU_IFLA_BR_MCAST_HASH_ELASTICITY
:
491 case QEMU_IFLA_BR_MCAST_HASH_MAX
:
492 case QEMU_IFLA_BR_MCAST_LAST_MEMBER_CNT
:
493 case QEMU_IFLA_BR_MCAST_STARTUP_QUERY_CNT
:
494 u32
= NLA_DATA(nlattr
);
495 *u32
= tswap32(*u32
);
498 case QEMU_IFLA_BR_HELLO_TIMER
:
499 case QEMU_IFLA_BR_TCN_TIMER
:
500 case QEMU_IFLA_BR_GC_TIMER
:
501 case QEMU_IFLA_BR_TOPOLOGY_CHANGE_TIMER
:
502 case QEMU_IFLA_BR_MCAST_LAST_MEMBER_INTVL
:
503 case QEMU_IFLA_BR_MCAST_MEMBERSHIP_INTVL
:
504 case QEMU_IFLA_BR_MCAST_QUERIER_INTVL
:
505 case QEMU_IFLA_BR_MCAST_QUERY_INTVL
:
506 case QEMU_IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
:
507 case QEMU_IFLA_BR_MCAST_STARTUP_QUERY_INTVL
:
508 u64
= NLA_DATA(nlattr
);
509 *u64
= tswap64(*u64
);
511 /* ifla_bridge_id: uin8_t[] */
512 case QEMU_IFLA_BR_ROOT_ID
:
513 case QEMU_IFLA_BR_BRIDGE_ID
:
515 /* br_boolopt_multi { uint32_t, uint32_t } */
516 case QEMU_IFLA_BR_MULTI_BOOLOPT
:
517 u32
= NLA_DATA(nlattr
);
518 u32
[0] = tswap32(u32
[0]); /* optval */
519 u32
[1] = tswap32(u32
[1]); /* optmask */
522 qemu_log_mask(LOG_UNIMP
, "Unknown QEMU_IFLA_BR type %d\n",
529 static abi_long
host_to_target_slave_data_bridge_nlattr(struct nlattr
*nlattr
,
536 switch (nlattr
->nla_type
) {
538 case QEMU_IFLA_BRPORT_STATE
:
539 case QEMU_IFLA_BRPORT_MODE
:
540 case QEMU_IFLA_BRPORT_GUARD
:
541 case QEMU_IFLA_BRPORT_PROTECT
:
542 case QEMU_IFLA_BRPORT_FAST_LEAVE
:
543 case QEMU_IFLA_BRPORT_LEARNING
:
544 case QEMU_IFLA_BRPORT_UNICAST_FLOOD
:
545 case QEMU_IFLA_BRPORT_PROXYARP
:
546 case QEMU_IFLA_BRPORT_LEARNING_SYNC
:
547 case QEMU_IFLA_BRPORT_PROXYARP_WIFI
:
548 case QEMU_IFLA_BRPORT_TOPOLOGY_CHANGE_ACK
:
549 case QEMU_IFLA_BRPORT_CONFIG_PENDING
:
550 case QEMU_IFLA_BRPORT_MULTICAST_ROUTER
:
551 case QEMU_IFLA_BRPORT_MCAST_FLOOD
:
552 case QEMU_IFLA_BRPORT_MCAST_TO_UCAST
:
553 case QEMU_IFLA_BRPORT_VLAN_TUNNEL
:
554 case QEMU_IFLA_BRPORT_BCAST_FLOOD
:
555 case QEMU_IFLA_BRPORT_NEIGH_SUPPRESS
:
556 case QEMU_IFLA_BRPORT_ISOLATED
:
557 case QEMU_IFLA_BRPORT_MRP_RING_OPEN
:
558 case QEMU_IFLA_BRPORT_MRP_IN_OPEN
:
561 case QEMU_IFLA_BRPORT_PRIORITY
:
562 case QEMU_IFLA_BRPORT_DESIGNATED_PORT
:
563 case QEMU_IFLA_BRPORT_DESIGNATED_COST
:
564 case QEMU_IFLA_BRPORT_ID
:
565 case QEMU_IFLA_BRPORT_NO
:
566 case QEMU_IFLA_BRPORT_GROUP_FWD_MASK
:
567 u16
= NLA_DATA(nlattr
);
568 *u16
= tswap16(*u16
);
571 case QEMU_IFLA_BRPORT_COST
:
572 case QEMU_IFLA_BRPORT_BACKUP_PORT
:
573 u32
= NLA_DATA(nlattr
);
574 *u32
= tswap32(*u32
);
577 case QEMU_IFLA_BRPORT_MESSAGE_AGE_TIMER
:
578 case QEMU_IFLA_BRPORT_FORWARD_DELAY_TIMER
:
579 case QEMU_IFLA_BRPORT_HOLD_TIMER
:
580 u64
= NLA_DATA(nlattr
);
581 *u64
= tswap64(*u64
);
583 /* ifla_bridge_id: uint8_t[] */
584 case QEMU_IFLA_BRPORT_ROOT_ID
:
585 case QEMU_IFLA_BRPORT_BRIDGE_ID
:
588 qemu_log_mask(LOG_UNIMP
, "Unknown QEMU_IFLA_BRPORT type %d\n",
595 static abi_long
host_to_target_data_tun_nlattr(struct nlattr
*nlattr
,
600 switch (nlattr
->nla_type
) {
602 case QEMU_IFLA_TUN_TYPE
:
603 case QEMU_IFLA_TUN_PI
:
604 case QEMU_IFLA_TUN_VNET_HDR
:
605 case QEMU_IFLA_TUN_PERSIST
:
606 case QEMU_IFLA_TUN_MULTI_QUEUE
:
609 case QEMU_IFLA_TUN_NUM_QUEUES
:
610 case QEMU_IFLA_TUN_NUM_DISABLED_QUEUES
:
611 case QEMU_IFLA_TUN_OWNER
:
612 case QEMU_IFLA_TUN_GROUP
:
613 u32
= NLA_DATA(nlattr
);
614 *u32
= tswap32(*u32
);
617 qemu_log_mask(LOG_UNIMP
, "Unknown QEMU_IFLA_TUN type %d\n",
624 struct linkinfo_context
{
631 static abi_long
host_to_target_data_linkinfo_nlattr(struct nlattr
*nlattr
,
634 struct linkinfo_context
*li_context
= context
;
636 switch (nlattr
->nla_type
) {
638 case QEMU_IFLA_INFO_KIND
:
639 li_context
->name
= NLA_DATA(nlattr
);
640 li_context
->len
= nlattr
->nla_len
- NLA_HDRLEN
;
642 case QEMU_IFLA_INFO_SLAVE_KIND
:
643 li_context
->slave_name
= NLA_DATA(nlattr
);
644 li_context
->slave_len
= nlattr
->nla_len
- NLA_HDRLEN
;
647 case QEMU_IFLA_INFO_XSTATS
:
648 /* FIXME: only used by CAN */
651 case QEMU_IFLA_INFO_DATA
:
652 if (strncmp(li_context
->name
, "bridge",
653 li_context
->len
) == 0) {
654 return host_to_target_for_each_nlattr(NLA_DATA(nlattr
),
657 host_to_target_data_bridge_nlattr
);
658 } else if (strncmp(li_context
->name
, "tun",
659 li_context
->len
) == 0) {
660 return host_to_target_for_each_nlattr(NLA_DATA(nlattr
),
663 host_to_target_data_tun_nlattr
);
665 qemu_log_mask(LOG_UNIMP
, "Unknown QEMU_IFLA_INFO_KIND %s\n",
669 case QEMU_IFLA_INFO_SLAVE_DATA
:
670 if (strncmp(li_context
->slave_name
, "bridge",
671 li_context
->slave_len
) == 0) {
672 return host_to_target_for_each_nlattr(NLA_DATA(nlattr
),
675 host_to_target_slave_data_bridge_nlattr
);
677 qemu_log_mask(LOG_UNIMP
, "Unknown QEMU_IFLA_INFO_SLAVE_KIND %s\n",
678 li_context
->slave_name
);
682 qemu_log_mask(LOG_UNIMP
, "Unknown host QEMU_IFLA_INFO type: %d\n",
690 static abi_long
host_to_target_data_inet_nlattr(struct nlattr
*nlattr
,
696 switch (nlattr
->nla_type
) {
697 case QEMU_IFLA_INET_CONF
:
698 u32
= NLA_DATA(nlattr
);
699 for (i
= 0; i
< (nlattr
->nla_len
- NLA_HDRLEN
) / sizeof(*u32
);
701 u32
[i
] = tswap32(u32
[i
]);
705 qemu_log_mask(LOG_UNIMP
, "Unknown host AF_INET type: %d\n",
711 static abi_long
host_to_target_data_inet6_nlattr(struct nlattr
*nlattr
,
716 struct ifla_cacheinfo
*ci
;
719 switch (nlattr
->nla_type
) {
721 case QEMU_IFLA_INET6_TOKEN
:
724 case QEMU_IFLA_INET6_ADDR_GEN_MODE
:
727 case QEMU_IFLA_INET6_FLAGS
:
728 u32
= NLA_DATA(nlattr
);
729 *u32
= tswap32(*u32
);
732 case QEMU_IFLA_INET6_CONF
:
733 u32
= NLA_DATA(nlattr
);
734 for (i
= 0; i
< (nlattr
->nla_len
- NLA_HDRLEN
) / sizeof(*u32
);
736 u32
[i
] = tswap32(u32
[i
]);
740 case QEMU_IFLA_INET6_CACHEINFO
:
741 ci
= NLA_DATA(nlattr
);
742 ci
->max_reasm_len
= tswap32(ci
->max_reasm_len
);
743 ci
->tstamp
= tswap32(ci
->tstamp
);
744 ci
->reachable_time
= tswap32(ci
->reachable_time
);
745 ci
->retrans_time
= tswap32(ci
->retrans_time
);
748 case QEMU_IFLA_INET6_STATS
:
749 case QEMU_IFLA_INET6_ICMP6STATS
:
750 u64
= NLA_DATA(nlattr
);
751 for (i
= 0; i
< (nlattr
->nla_len
- NLA_HDRLEN
) / sizeof(*u64
);
753 u64
[i
] = tswap64(u64
[i
]);
757 qemu_log_mask(LOG_UNIMP
, "Unknown host AF_INET6 type: %d\n",
763 static abi_long
host_to_target_data_spec_nlattr(struct nlattr
*nlattr
,
766 switch (nlattr
->nla_type
) {
768 return host_to_target_for_each_nlattr(NLA_DATA(nlattr
), nlattr
->nla_len
,
770 host_to_target_data_inet_nlattr
);
772 return host_to_target_for_each_nlattr(NLA_DATA(nlattr
), nlattr
->nla_len
,
774 host_to_target_data_inet6_nlattr
);
776 qemu_log_mask(LOG_UNIMP
, "Unknown host AF_SPEC type: %d\n",
783 static abi_long
host_to_target_data_xdp_nlattr(struct nlattr
*nlattr
,
788 switch (nlattr
->nla_type
) {
790 case QEMU_IFLA_XDP_ATTACHED
:
793 case QEMU_IFLA_XDP_PROG_ID
:
794 u32
= NLA_DATA(nlattr
);
795 *u32
= tswap32(*u32
);
799 LOG_UNIMP
, "Unknown host XDP type: %d\n", nlattr
->nla_type
);
805 static abi_long
host_to_target_data_link_rtattr(struct rtattr
*rtattr
)
808 struct rtnl_link_stats
*st
;
809 struct rtnl_link_stats64
*st64
;
810 struct rtnl_link_ifmap
*map
;
811 struct linkinfo_context li_context
;
813 switch (rtattr
->rta_type
) {
815 case QEMU_IFLA_ADDRESS
:
816 case QEMU_IFLA_BROADCAST
:
817 case QEMU_IFLA_PERM_ADDRESS
:
819 case QEMU_IFLA_IFNAME
:
820 case QEMU_IFLA_QDISC
:
823 case QEMU_IFLA_OPERSTATE
:
824 case QEMU_IFLA_LINKMODE
:
825 case QEMU_IFLA_CARRIER
:
826 case QEMU_IFLA_PROTO_DOWN
:
831 case QEMU_IFLA_WEIGHT
:
832 case QEMU_IFLA_TXQLEN
:
833 case QEMU_IFLA_CARRIER_CHANGES
:
834 case QEMU_IFLA_NUM_RX_QUEUES
:
835 case QEMU_IFLA_NUM_TX_QUEUES
:
836 case QEMU_IFLA_PROMISCUITY
:
837 case QEMU_IFLA_EXT_MASK
:
838 case QEMU_IFLA_LINK_NETNSID
:
839 case QEMU_IFLA_GROUP
:
840 case QEMU_IFLA_MASTER
:
841 case QEMU_IFLA_NUM_VF
:
842 case QEMU_IFLA_GSO_MAX_SEGS
:
843 case QEMU_IFLA_GSO_MAX_SIZE
:
844 case QEMU_IFLA_CARRIER_UP_COUNT
:
845 case QEMU_IFLA_CARRIER_DOWN_COUNT
:
846 case QEMU_IFLA_MIN_MTU
:
847 case QEMU_IFLA_MAX_MTU
:
848 u32
= RTA_DATA(rtattr
);
849 *u32
= tswap32(*u32
);
851 /* struct rtnl_link_stats */
852 case QEMU_IFLA_STATS
:
853 st
= RTA_DATA(rtattr
);
854 st
->rx_packets
= tswap32(st
->rx_packets
);
855 st
->tx_packets
= tswap32(st
->tx_packets
);
856 st
->rx_bytes
= tswap32(st
->rx_bytes
);
857 st
->tx_bytes
= tswap32(st
->tx_bytes
);
858 st
->rx_errors
= tswap32(st
->rx_errors
);
859 st
->tx_errors
= tswap32(st
->tx_errors
);
860 st
->rx_dropped
= tswap32(st
->rx_dropped
);
861 st
->tx_dropped
= tswap32(st
->tx_dropped
);
862 st
->multicast
= tswap32(st
->multicast
);
863 st
->collisions
= tswap32(st
->collisions
);
865 /* detailed rx_errors: */
866 st
->rx_length_errors
= tswap32(st
->rx_length_errors
);
867 st
->rx_over_errors
= tswap32(st
->rx_over_errors
);
868 st
->rx_crc_errors
= tswap32(st
->rx_crc_errors
);
869 st
->rx_frame_errors
= tswap32(st
->rx_frame_errors
);
870 st
->rx_fifo_errors
= tswap32(st
->rx_fifo_errors
);
871 st
->rx_missed_errors
= tswap32(st
->rx_missed_errors
);
873 /* detailed tx_errors */
874 st
->tx_aborted_errors
= tswap32(st
->tx_aborted_errors
);
875 st
->tx_carrier_errors
= tswap32(st
->tx_carrier_errors
);
876 st
->tx_fifo_errors
= tswap32(st
->tx_fifo_errors
);
877 st
->tx_heartbeat_errors
= tswap32(st
->tx_heartbeat_errors
);
878 st
->tx_window_errors
= tswap32(st
->tx_window_errors
);
881 st
->rx_compressed
= tswap32(st
->rx_compressed
);
882 st
->tx_compressed
= tswap32(st
->tx_compressed
);
884 /* struct rtnl_link_stats64 */
885 case QEMU_IFLA_STATS64
:
886 st64
= RTA_DATA(rtattr
);
887 st64
->rx_packets
= tswap64(st64
->rx_packets
);
888 st64
->tx_packets
= tswap64(st64
->tx_packets
);
889 st64
->rx_bytes
= tswap64(st64
->rx_bytes
);
890 st64
->tx_bytes
= tswap64(st64
->tx_bytes
);
891 st64
->rx_errors
= tswap64(st64
->rx_errors
);
892 st64
->tx_errors
= tswap64(st64
->tx_errors
);
893 st64
->rx_dropped
= tswap64(st64
->rx_dropped
);
894 st64
->tx_dropped
= tswap64(st64
->tx_dropped
);
895 st64
->multicast
= tswap64(st64
->multicast
);
896 st64
->collisions
= tswap64(st64
->collisions
);
898 /* detailed rx_errors: */
899 st64
->rx_length_errors
= tswap64(st64
->rx_length_errors
);
900 st64
->rx_over_errors
= tswap64(st64
->rx_over_errors
);
901 st64
->rx_crc_errors
= tswap64(st64
->rx_crc_errors
);
902 st64
->rx_frame_errors
= tswap64(st64
->rx_frame_errors
);
903 st64
->rx_fifo_errors
= tswap64(st64
->rx_fifo_errors
);
904 st64
->rx_missed_errors
= tswap64(st64
->rx_missed_errors
);
906 /* detailed tx_errors */
907 st64
->tx_aborted_errors
= tswap64(st64
->tx_aborted_errors
);
908 st64
->tx_carrier_errors
= tswap64(st64
->tx_carrier_errors
);
909 st64
->tx_fifo_errors
= tswap64(st64
->tx_fifo_errors
);
910 st64
->tx_heartbeat_errors
= tswap64(st64
->tx_heartbeat_errors
);
911 st64
->tx_window_errors
= tswap64(st64
->tx_window_errors
);
914 st64
->rx_compressed
= tswap64(st64
->rx_compressed
);
915 st64
->tx_compressed
= tswap64(st64
->tx_compressed
);
917 /* struct rtnl_link_ifmap */
919 map
= RTA_DATA(rtattr
);
920 map
->mem_start
= tswap64(map
->mem_start
);
921 map
->mem_end
= tswap64(map
->mem_end
);
922 map
->base_addr
= tswap64(map
->base_addr
);
923 map
->irq
= tswap16(map
->irq
);
926 case QEMU_IFLA_LINKINFO
:
927 memset(&li_context
, 0, sizeof(li_context
));
928 return host_to_target_for_each_nlattr(RTA_DATA(rtattr
), rtattr
->rta_len
,
930 host_to_target_data_linkinfo_nlattr
);
931 case QEMU_IFLA_AF_SPEC
:
932 return host_to_target_for_each_nlattr(RTA_DATA(rtattr
), rtattr
->rta_len
,
934 host_to_target_data_spec_nlattr
);
936 return host_to_target_for_each_nlattr(RTA_DATA(rtattr
), rtattr
->rta_len
,
938 host_to_target_data_xdp_nlattr
);
940 qemu_log_mask(LOG_UNIMP
, "Unknown host QEMU_IFLA type: %d\n",
947 static abi_long
host_to_target_data_addr_rtattr(struct rtattr
*rtattr
)
950 struct ifa_cacheinfo
*ci
;
952 switch (rtattr
->rta_type
) {
953 /* binary: depends on family type */
963 u32
= RTA_DATA(rtattr
);
964 *u32
= tswap32(*u32
);
966 /* struct ifa_cacheinfo */
968 ci
= RTA_DATA(rtattr
);
969 ci
->ifa_prefered
= tswap32(ci
->ifa_prefered
);
970 ci
->ifa_valid
= tswap32(ci
->ifa_valid
);
971 ci
->cstamp
= tswap32(ci
->cstamp
);
972 ci
->tstamp
= tswap32(ci
->tstamp
);
976 LOG_UNIMP
, "Unknown host IFA type: %d\n", rtattr
->rta_type
);
982 static abi_long
host_to_target_data_route_rtattr(struct rtattr
*rtattr
)
985 struct rta_cacheinfo
*ci
;
987 switch (rtattr
->rta_type
) {
988 /* binary: depends on family type */
989 case QEMU_RTA_GATEWAY
:
991 case QEMU_RTA_PREFSRC
:
997 case QEMU_RTA_PRIORITY
:
1000 u32
= RTA_DATA(rtattr
);
1001 *u32
= tswap32(*u32
);
1003 /* struct rta_cacheinfo */
1004 case QEMU_RTA_CACHEINFO
:
1005 ci
= RTA_DATA(rtattr
);
1006 ci
->rta_clntref
= tswap32(ci
->rta_clntref
);
1007 ci
->rta_lastuse
= tswap32(ci
->rta_lastuse
);
1008 ci
->rta_expires
= tswap32(ci
->rta_expires
);
1009 ci
->rta_error
= tswap32(ci
->rta_error
);
1010 ci
->rta_used
= tswap32(ci
->rta_used
);
1011 #if defined(RTNETLINK_HAVE_PEERINFO)
1012 ci
->rta_id
= tswap32(ci
->rta_id
);
1013 ci
->rta_ts
= tswap32(ci
->rta_ts
);
1014 ci
->rta_tsage
= tswap32(ci
->rta_tsage
);
1019 LOG_UNIMP
, "Unknown host RTA type: %d\n", rtattr
->rta_type
);
1025 static abi_long
host_to_target_link_rtattr(struct rtattr
*rtattr
,
1026 uint32_t rtattr_len
)
1028 return host_to_target_for_each_rtattr(rtattr
, rtattr_len
,
1029 host_to_target_data_link_rtattr
);
1032 static abi_long
host_to_target_addr_rtattr(struct rtattr
*rtattr
,
1033 uint32_t rtattr_len
)
1035 return host_to_target_for_each_rtattr(rtattr
, rtattr_len
,
1036 host_to_target_data_addr_rtattr
);
1039 static abi_long
host_to_target_route_rtattr(struct rtattr
*rtattr
,
1040 uint32_t rtattr_len
)
1042 return host_to_target_for_each_rtattr(rtattr
, rtattr_len
,
1043 host_to_target_data_route_rtattr
);
1046 static abi_long
host_to_target_data_route(struct nlmsghdr
*nlh
)
1049 struct ifinfomsg
*ifi
;
1050 struct ifaddrmsg
*ifa
;
1053 nlmsg_len
= nlh
->nlmsg_len
;
1054 switch (nlh
->nlmsg_type
) {
1058 if (nlh
->nlmsg_len
>= NLMSG_LENGTH(sizeof(*ifi
))) {
1059 ifi
= NLMSG_DATA(nlh
);
1060 ifi
->ifi_type
= tswap16(ifi
->ifi_type
);
1061 ifi
->ifi_index
= tswap32(ifi
->ifi_index
);
1062 ifi
->ifi_flags
= tswap32(ifi
->ifi_flags
);
1063 ifi
->ifi_change
= tswap32(ifi
->ifi_change
);
1064 host_to_target_link_rtattr(IFLA_RTA(ifi
),
1065 nlmsg_len
- NLMSG_LENGTH(sizeof(*ifi
)));
1071 if (nlh
->nlmsg_len
>= NLMSG_LENGTH(sizeof(*ifa
))) {
1072 ifa
= NLMSG_DATA(nlh
);
1073 ifa
->ifa_index
= tswap32(ifa
->ifa_index
);
1074 host_to_target_addr_rtattr(IFA_RTA(ifa
),
1075 nlmsg_len
- NLMSG_LENGTH(sizeof(*ifa
)));
1081 if (nlh
->nlmsg_len
>= NLMSG_LENGTH(sizeof(*rtm
))) {
1082 rtm
= NLMSG_DATA(nlh
);
1083 rtm
->rtm_flags
= tswap32(rtm
->rtm_flags
);
1084 host_to_target_route_rtattr(RTM_RTA(rtm
),
1085 nlmsg_len
- NLMSG_LENGTH(sizeof(*rtm
)));
1089 return -TARGET_EINVAL
;
1094 static inline abi_long
host_to_target_nlmsg_route(struct nlmsghdr
*nlh
,
1097 return host_to_target_for_each_nlmsg(nlh
, len
, host_to_target_data_route
);
1100 static abi_long
target_to_host_for_each_rtattr(struct rtattr
*rtattr
,
1102 abi_long (*target_to_host_rtattr
)
1105 unsigned short aligned_rta_len
;
1108 while (len
>= sizeof(struct rtattr
)) {
1109 if (tswap16(rtattr
->rta_len
) < sizeof(struct rtattr
) ||
1110 tswap16(rtattr
->rta_len
) > len
) {
1113 rtattr
->rta_len
= tswap16(rtattr
->rta_len
);
1114 rtattr
->rta_type
= tswap16(rtattr
->rta_type
);
1115 ret
= target_to_host_rtattr(rtattr
);
1120 aligned_rta_len
= RTA_ALIGN(rtattr
->rta_len
);
1121 if (aligned_rta_len
>= len
) {
1124 len
-= aligned_rta_len
;
1125 rtattr
= (struct rtattr
*)(((char *)rtattr
) + aligned_rta_len
);
1130 static abi_long
target_to_host_data_link_rtattr(struct rtattr
*rtattr
)
1134 switch (rtattr
->rta_type
) {
1136 case QEMU_IFLA_EXT_MASK
:
1137 u32
= RTA_DATA(rtattr
);
1138 *u32
= tswap32(*u32
);
1141 qemu_log_mask(LOG_UNIMP
, "Unknown target QEMU_IFLA type: %d\n",
1148 static abi_long
target_to_host_data_addr_rtattr(struct rtattr
*rtattr
)
1150 switch (rtattr
->rta_type
) {
1151 /* binary: depends on family type */
1156 qemu_log_mask(LOG_UNIMP
, "Unknown target IFA type: %d\n",
1163 static abi_long
target_to_host_data_route_rtattr(struct rtattr
*rtattr
)
1166 switch (rtattr
->rta_type
) {
1167 /* binary: depends on family type */
1170 case QEMU_RTA_GATEWAY
:
1173 case QEMU_RTA_PRIORITY
:
1174 case QEMU_RTA_TABLE
:
1176 u32
= RTA_DATA(rtattr
);
1177 *u32
= tswap32(*u32
);
1180 qemu_log_mask(LOG_UNIMP
, "Unknown target RTA type: %d\n",
1187 static void target_to_host_link_rtattr(struct rtattr
*rtattr
,
1188 uint32_t rtattr_len
)
1190 target_to_host_for_each_rtattr(rtattr
, rtattr_len
,
1191 target_to_host_data_link_rtattr
);
1194 static void target_to_host_addr_rtattr(struct rtattr
*rtattr
,
1195 uint32_t rtattr_len
)
1197 target_to_host_for_each_rtattr(rtattr
, rtattr_len
,
1198 target_to_host_data_addr_rtattr
);
1201 static void target_to_host_route_rtattr(struct rtattr
*rtattr
,
1202 uint32_t rtattr_len
)
1204 target_to_host_for_each_rtattr(rtattr
, rtattr_len
,
1205 target_to_host_data_route_rtattr
);
1208 static abi_long
target_to_host_data_route(struct nlmsghdr
*nlh
)
1210 struct ifinfomsg
*ifi
;
1211 struct ifaddrmsg
*ifa
;
1214 switch (nlh
->nlmsg_type
) {
1219 if (nlh
->nlmsg_len
>= NLMSG_LENGTH(sizeof(*ifi
))) {
1220 ifi
= NLMSG_DATA(nlh
);
1221 ifi
->ifi_type
= tswap16(ifi
->ifi_type
);
1222 ifi
->ifi_index
= tswap32(ifi
->ifi_index
);
1223 ifi
->ifi_flags
= tswap32(ifi
->ifi_flags
);
1224 ifi
->ifi_change
= tswap32(ifi
->ifi_change
);
1225 target_to_host_link_rtattr(IFLA_RTA(ifi
), nlh
->nlmsg_len
-
1226 NLMSG_LENGTH(sizeof(*ifi
)));
1232 if (nlh
->nlmsg_len
>= NLMSG_LENGTH(sizeof(*ifa
))) {
1233 ifa
= NLMSG_DATA(nlh
);
1234 ifa
->ifa_index
= tswap32(ifa
->ifa_index
);
1235 target_to_host_addr_rtattr(IFA_RTA(ifa
), nlh
->nlmsg_len
-
1236 NLMSG_LENGTH(sizeof(*ifa
)));
1242 if (nlh
->nlmsg_len
>= NLMSG_LENGTH(sizeof(*rtm
))) {
1243 rtm
= NLMSG_DATA(nlh
);
1244 rtm
->rtm_flags
= tswap32(rtm
->rtm_flags
);
1245 target_to_host_route_rtattr(RTM_RTA(rtm
), nlh
->nlmsg_len
-
1246 NLMSG_LENGTH(sizeof(*rtm
)));
1250 return -TARGET_EOPNOTSUPP
;
1255 static abi_long
target_to_host_nlmsg_route(struct nlmsghdr
*nlh
, size_t len
)
1257 return target_to_host_for_each_nlmsg(nlh
, len
, target_to_host_data_route
);
1259 #endif /* CONFIG_RTNETLINK */
1261 static abi_long
host_to_target_data_audit(struct nlmsghdr
*nlh
)
1263 switch (nlh
->nlmsg_type
) {
1265 qemu_log_mask(LOG_UNIMP
, "Unknown host audit message type %d\n",
1267 return -TARGET_EINVAL
;
1272 static inline abi_long
host_to_target_nlmsg_audit(struct nlmsghdr
*nlh
,
1275 return host_to_target_for_each_nlmsg(nlh
, len
, host_to_target_data_audit
);
1278 static abi_long
target_to_host_data_audit(struct nlmsghdr
*nlh
)
1280 switch (nlh
->nlmsg_type
) {
1282 case AUDIT_FIRST_USER_MSG
... AUDIT_LAST_USER_MSG
:
1283 case AUDIT_FIRST_USER_MSG2
... AUDIT_LAST_USER_MSG2
:
1286 qemu_log_mask(LOG_UNIMP
, "Unknown target audit message type %d\n",
1288 return -TARGET_EINVAL
;
1294 static abi_long
target_to_host_nlmsg_audit(struct nlmsghdr
*nlh
, size_t len
)
1296 return target_to_host_for_each_nlmsg(nlh
, len
, target_to_host_data_audit
);
1299 static abi_long
packet_target_to_host_sockaddr(void *host_addr
,
1300 abi_ulong target_addr
,
1303 struct sockaddr
*addr
= host_addr
;
1304 struct target_sockaddr
*target_saddr
;
1306 target_saddr
= lock_user(VERIFY_READ
, target_addr
, len
, 1);
1307 if (!target_saddr
) {
1308 return -TARGET_EFAULT
;
1311 memcpy(addr
, target_saddr
, len
);
1312 addr
->sa_family
= tswap16(target_saddr
->sa_family
);
1313 /* spkt_protocol is big-endian */
1315 unlock_user(target_saddr
, target_addr
, 0);
1319 TargetFdTrans target_packet_trans
= {
1320 .target_to_host_addr
= packet_target_to_host_sockaddr
,
1323 #ifdef CONFIG_RTNETLINK
1324 static abi_long
netlink_route_target_to_host(void *buf
, size_t len
)
1328 ret
= target_to_host_nlmsg_route(buf
, len
);
1336 static abi_long
netlink_route_host_to_target(void *buf
, size_t len
)
1340 ret
= host_to_target_nlmsg_route(buf
, len
);
1348 TargetFdTrans target_netlink_route_trans
= {
1349 .target_to_host_data
= netlink_route_target_to_host
,
1350 .host_to_target_data
= netlink_route_host_to_target
,
1352 #endif /* CONFIG_RTNETLINK */
1354 static abi_long
netlink_audit_target_to_host(void *buf
, size_t len
)
1358 ret
= target_to_host_nlmsg_audit(buf
, len
);
1366 static abi_long
netlink_audit_host_to_target(void *buf
, size_t len
)
1370 ret
= host_to_target_nlmsg_audit(buf
, len
);
1378 TargetFdTrans target_netlink_audit_trans
= {
1379 .target_to_host_data
= netlink_audit_target_to_host
,
1380 .host_to_target_data
= netlink_audit_host_to_target
,
1383 /* signalfd siginfo conversion */
1386 host_to_target_signalfd_siginfo(struct signalfd_siginfo
*tinfo
,
1387 const struct signalfd_siginfo
*info
)
1389 int sig
= host_to_target_signal(info
->ssi_signo
);
1391 /* linux/signalfd.h defines a ssi_addr_lsb
1392 * not defined in sys/signalfd.h but used by some kernels
1395 #ifdef BUS_MCEERR_AO
1396 if (tinfo
->ssi_signo
== SIGBUS
&&
1397 (tinfo
->ssi_code
== BUS_MCEERR_AR
||
1398 tinfo
->ssi_code
== BUS_MCEERR_AO
)) {
1399 uint16_t *ssi_addr_lsb
= (uint16_t *)(&info
->ssi_addr
+ 1);
1400 uint16_t *tssi_addr_lsb
= (uint16_t *)(&tinfo
->ssi_addr
+ 1);
1401 *tssi_addr_lsb
= tswap16(*ssi_addr_lsb
);
1405 tinfo
->ssi_signo
= tswap32(sig
);
1406 tinfo
->ssi_errno
= tswap32(tinfo
->ssi_errno
);
1407 tinfo
->ssi_code
= tswap32(info
->ssi_code
);
1408 tinfo
->ssi_pid
= tswap32(info
->ssi_pid
);
1409 tinfo
->ssi_uid
= tswap32(info
->ssi_uid
);
1410 tinfo
->ssi_fd
= tswap32(info
->ssi_fd
);
1411 tinfo
->ssi_tid
= tswap32(info
->ssi_tid
);
1412 tinfo
->ssi_band
= tswap32(info
->ssi_band
);
1413 tinfo
->ssi_overrun
= tswap32(info
->ssi_overrun
);
1414 tinfo
->ssi_trapno
= tswap32(info
->ssi_trapno
);
1415 tinfo
->ssi_status
= tswap32(info
->ssi_status
);
1416 tinfo
->ssi_int
= tswap32(info
->ssi_int
);
1417 tinfo
->ssi_ptr
= tswap64(info
->ssi_ptr
);
1418 tinfo
->ssi_utime
= tswap64(info
->ssi_utime
);
1419 tinfo
->ssi_stime
= tswap64(info
->ssi_stime
);
1420 tinfo
->ssi_addr
= tswap64(info
->ssi_addr
);
1423 static abi_long
host_to_target_data_signalfd(void *buf
, size_t len
)
1427 for (i
= 0; i
< len
; i
+= sizeof(struct signalfd_siginfo
)) {
1428 host_to_target_signalfd_siginfo(buf
+ i
, buf
+ i
);
1434 TargetFdTrans target_signalfd_trans
= {
1435 .host_to_target_data
= host_to_target_data_signalfd
,
1438 static abi_long
swap_data_eventfd(void *buf
, size_t len
)
1440 uint64_t *counter
= buf
;
1443 if (len
< sizeof(uint64_t)) {
1447 for (i
= 0; i
< len
; i
+= sizeof(uint64_t)) {
1448 *counter
= tswap64(*counter
);
1455 TargetFdTrans target_eventfd_trans
= {
1456 .host_to_target_data
= swap_data_eventfd
,
1457 .target_to_host_data
= swap_data_eventfd
,
1460 #if (defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)) || \
1461 (defined(CONFIG_INOTIFY1) && defined(TARGET_NR_inotify_init1) && \
1462 defined(__NR_inotify_init1))
1463 static abi_long
host_to_target_data_inotify(void *buf
, size_t len
)
1465 struct inotify_event
*ev
;
1469 for (i
= 0; i
< len
; i
+= sizeof(struct inotify_event
) + name_len
) {
1470 ev
= (struct inotify_event
*)((char *)buf
+ i
);
1473 ev
->wd
= tswap32(ev
->wd
);
1474 ev
->mask
= tswap32(ev
->mask
);
1475 ev
->cookie
= tswap32(ev
->cookie
);
1476 ev
->len
= tswap32(name_len
);
1482 TargetFdTrans target_inotify_trans
= {
1483 .host_to_target_data
= host_to_target_data_inotify
,