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
,
140 QEMU_IFLA_BRPORT_UNSPEC
,
141 QEMU_IFLA_BRPORT_STATE
,
142 QEMU_IFLA_BRPORT_PRIORITY
,
143 QEMU_IFLA_BRPORT_COST
,
144 QEMU_IFLA_BRPORT_MODE
,
145 QEMU_IFLA_BRPORT_GUARD
,
146 QEMU_IFLA_BRPORT_PROTECT
,
147 QEMU_IFLA_BRPORT_FAST_LEAVE
,
148 QEMU_IFLA_BRPORT_LEARNING
,
149 QEMU_IFLA_BRPORT_UNICAST_FLOOD
,
150 QEMU_IFLA_BRPORT_PROXYARP
,
151 QEMU_IFLA_BRPORT_LEARNING_SYNC
,
152 QEMU_IFLA_BRPORT_PROXYARP_WIFI
,
153 QEMU_IFLA_BRPORT_ROOT_ID
,
154 QEMU_IFLA_BRPORT_BRIDGE_ID
,
155 QEMU_IFLA_BRPORT_DESIGNATED_PORT
,
156 QEMU_IFLA_BRPORT_DESIGNATED_COST
,
159 QEMU_IFLA_BRPORT_TOPOLOGY_CHANGE_ACK
,
160 QEMU_IFLA_BRPORT_CONFIG_PENDING
,
161 QEMU_IFLA_BRPORT_MESSAGE_AGE_TIMER
,
162 QEMU_IFLA_BRPORT_FORWARD_DELAY_TIMER
,
163 QEMU_IFLA_BRPORT_HOLD_TIMER
,
164 QEMU_IFLA_BRPORT_FLUSH
,
165 QEMU_IFLA_BRPORT_MULTICAST_ROUTER
,
166 QEMU_IFLA_BRPORT_PAD
,
167 QEMU_IFLA_BRPORT_MCAST_FLOOD
,
168 QEMU_IFLA_BRPORT_MCAST_TO_UCAST
,
169 QEMU_IFLA_BRPORT_VLAN_TUNNEL
,
170 QEMU_IFLA_BRPORT_BCAST_FLOOD
,
171 QEMU_IFLA_BRPORT_GROUP_FWD_MASK
,
172 QEMU_IFLA_BRPORT_NEIGH_SUPPRESS
,
173 QEMU_IFLA_BRPORT_ISOLATED
,
174 QEMU_IFLA_BRPORT_BACKUP_PORT
,
175 QEMU___IFLA_BRPORT_MAX
179 QEMU_IFLA_TUN_UNSPEC
,
184 QEMU_IFLA_TUN_VNET_HDR
,
185 QEMU_IFLA_TUN_PERSIST
,
186 QEMU_IFLA_TUN_MULTI_QUEUE
,
187 QEMU_IFLA_TUN_NUM_QUEUES
,
188 QEMU_IFLA_TUN_NUM_DISABLED_QUEUES
,
193 QEMU_IFLA_INFO_UNSPEC
,
196 QEMU_IFLA_INFO_XSTATS
,
197 QEMU_IFLA_INFO_SLAVE_KIND
,
198 QEMU_IFLA_INFO_SLAVE_DATA
,
199 QEMU___IFLA_INFO_MAX
,
203 QEMU_IFLA_INET_UNSPEC
,
205 QEMU___IFLA_INET_MAX
,
209 QEMU_IFLA_INET6_UNSPEC
,
210 QEMU_IFLA_INET6_FLAGS
,
211 QEMU_IFLA_INET6_CONF
,
212 QEMU_IFLA_INET6_STATS
,
213 QEMU_IFLA_INET6_MCAST
,
214 QEMU_IFLA_INET6_CACHEINFO
,
215 QEMU_IFLA_INET6_ICMP6STATS
,
216 QEMU_IFLA_INET6_TOKEN
,
217 QEMU_IFLA_INET6_ADDR_GEN_MODE
,
218 QEMU___IFLA_INET6_MAX
222 QEMU_IFLA_XDP_UNSPEC
,
224 QEMU_IFLA_XDP_ATTACHED
,
226 QEMU_IFLA_XDP_PROG_ID
,
241 QEMU_RTA_PROTOINFO
, /* no longer used */
244 QEMU_RTA_SESSION
, /* no longer used */
245 QEMU_RTA_MP_ALGO
, /* no longer used */
257 QEMU_RTA_TTL_PROPAGATE
,
264 TargetFdTrans
**target_fd_trans
;
265 unsigned int target_fd_max
;
267 static void tswap_nlmsghdr(struct nlmsghdr
*nlh
)
269 nlh
->nlmsg_len
= tswap32(nlh
->nlmsg_len
);
270 nlh
->nlmsg_type
= tswap16(nlh
->nlmsg_type
);
271 nlh
->nlmsg_flags
= tswap16(nlh
->nlmsg_flags
);
272 nlh
->nlmsg_seq
= tswap32(nlh
->nlmsg_seq
);
273 nlh
->nlmsg_pid
= tswap32(nlh
->nlmsg_pid
);
276 static abi_long
host_to_target_for_each_nlmsg(struct nlmsghdr
*nlh
,
278 abi_long (*host_to_target_nlmsg
)
282 uint32_t aligned_nlmsg_len
;
285 while (len
> sizeof(struct nlmsghdr
)) {
287 nlmsg_len
= nlh
->nlmsg_len
;
288 if (nlmsg_len
< sizeof(struct nlmsghdr
) ||
293 switch (nlh
->nlmsg_type
) {
301 struct nlmsgerr
*e
= NLMSG_DATA(nlh
);
302 e
->error
= tswap32(e
->error
);
303 tswap_nlmsghdr(&e
->msg
);
308 ret
= host_to_target_nlmsg(nlh
);
317 aligned_nlmsg_len
= NLMSG_ALIGN(nlmsg_len
);
318 if (aligned_nlmsg_len
>= len
) {
321 len
-= aligned_nlmsg_len
;
322 nlh
= (struct nlmsghdr
*)(((char*)nlh
) + aligned_nlmsg_len
);
327 static abi_long
target_to_host_for_each_nlmsg(struct nlmsghdr
*nlh
,
329 abi_long (*target_to_host_nlmsg
)
332 uint32_t aligned_nlmsg_len
;
335 while (len
> sizeof(struct nlmsghdr
)) {
336 if (tswap32(nlh
->nlmsg_len
) < sizeof(struct nlmsghdr
) ||
337 tswap32(nlh
->nlmsg_len
) > len
) {
341 switch (nlh
->nlmsg_type
) {
348 struct nlmsgerr
*e
= NLMSG_DATA(nlh
);
349 e
->error
= tswap32(e
->error
);
350 tswap_nlmsghdr(&e
->msg
);
354 ret
= target_to_host_nlmsg(nlh
);
360 aligned_nlmsg_len
= NLMSG_ALIGN(nlh
->nlmsg_len
);
361 if (aligned_nlmsg_len
>= len
) {
364 len
-= aligned_nlmsg_len
;
365 nlh
= (struct nlmsghdr
*)(((char *)nlh
) + aligned_nlmsg_len
);
370 #ifdef CONFIG_RTNETLINK
371 static abi_long
host_to_target_for_each_nlattr(struct nlattr
*nlattr
,
372 size_t len
, void *context
,
373 abi_long (*host_to_target_nlattr
)
377 unsigned short nla_len
;
378 unsigned short aligned_nla_len
;
381 while (len
> sizeof(struct nlattr
)) {
382 nla_len
= nlattr
->nla_len
;
383 if (nla_len
< sizeof(struct nlattr
) ||
387 ret
= host_to_target_nlattr(nlattr
, context
);
388 nlattr
->nla_len
= tswap16(nlattr
->nla_len
);
389 nlattr
->nla_type
= tswap16(nlattr
->nla_type
);
394 aligned_nla_len
= NLA_ALIGN(nla_len
);
395 if (aligned_nla_len
>= len
) {
398 len
-= aligned_nla_len
;
399 nlattr
= (struct nlattr
*)(((char *)nlattr
) + aligned_nla_len
);
404 static abi_long
host_to_target_for_each_rtattr(struct rtattr
*rtattr
,
406 abi_long (*host_to_target_rtattr
)
409 unsigned short rta_len
;
410 unsigned short aligned_rta_len
;
413 while (len
> sizeof(struct rtattr
)) {
414 rta_len
= rtattr
->rta_len
;
415 if (rta_len
< sizeof(struct rtattr
) ||
419 ret
= host_to_target_rtattr(rtattr
);
420 rtattr
->rta_len
= tswap16(rtattr
->rta_len
);
421 rtattr
->rta_type
= tswap16(rtattr
->rta_type
);
426 aligned_rta_len
= RTA_ALIGN(rta_len
);
427 if (aligned_rta_len
>= len
) {
430 len
-= aligned_rta_len
;
431 rtattr
= (struct rtattr
*)(((char *)rtattr
) + aligned_rta_len
);
436 #define NLA_DATA(nla) ((void *)((char *)(nla)) + NLA_HDRLEN)
438 static abi_long
host_to_target_data_bridge_nlattr(struct nlattr
*nlattr
,
445 switch (nlattr
->nla_type
) {
447 case QEMU_IFLA_BR_FDB_FLUSH
:
450 case QEMU_IFLA_BR_GROUP_ADDR
:
453 case QEMU_IFLA_BR_VLAN_FILTERING
:
454 case QEMU_IFLA_BR_TOPOLOGY_CHANGE
:
455 case QEMU_IFLA_BR_TOPOLOGY_CHANGE_DETECTED
:
456 case QEMU_IFLA_BR_MCAST_ROUTER
:
457 case QEMU_IFLA_BR_MCAST_SNOOPING
:
458 case QEMU_IFLA_BR_MCAST_QUERY_USE_IFADDR
:
459 case QEMU_IFLA_BR_MCAST_QUERIER
:
460 case QEMU_IFLA_BR_NF_CALL_IPTABLES
:
461 case QEMU_IFLA_BR_NF_CALL_IP6TABLES
:
462 case QEMU_IFLA_BR_NF_CALL_ARPTABLES
:
463 case QEMU_IFLA_BR_VLAN_STATS_ENABLED
:
464 case QEMU_IFLA_BR_MCAST_STATS_ENABLED
:
465 case QEMU_IFLA_BR_MCAST_IGMP_VERSION
:
466 case QEMU_IFLA_BR_MCAST_MLD_VERSION
:
467 case QEMU_IFLA_BR_VLAN_STATS_PER_PORT
:
470 case QEMU_IFLA_BR_PRIORITY
:
471 case QEMU_IFLA_BR_VLAN_PROTOCOL
:
472 case QEMU_IFLA_BR_GROUP_FWD_MASK
:
473 case QEMU_IFLA_BR_ROOT_PORT
:
474 case QEMU_IFLA_BR_VLAN_DEFAULT_PVID
:
475 u16
= NLA_DATA(nlattr
);
476 *u16
= tswap16(*u16
);
479 case QEMU_IFLA_BR_FORWARD_DELAY
:
480 case QEMU_IFLA_BR_HELLO_TIME
:
481 case QEMU_IFLA_BR_MAX_AGE
:
482 case QEMU_IFLA_BR_AGEING_TIME
:
483 case QEMU_IFLA_BR_STP_STATE
:
484 case QEMU_IFLA_BR_ROOT_PATH_COST
:
485 case QEMU_IFLA_BR_MCAST_HASH_ELASTICITY
:
486 case QEMU_IFLA_BR_MCAST_HASH_MAX
:
487 case QEMU_IFLA_BR_MCAST_LAST_MEMBER_CNT
:
488 case QEMU_IFLA_BR_MCAST_STARTUP_QUERY_CNT
:
489 u32
= NLA_DATA(nlattr
);
490 *u32
= tswap32(*u32
);
493 case QEMU_IFLA_BR_HELLO_TIMER
:
494 case QEMU_IFLA_BR_TCN_TIMER
:
495 case QEMU_IFLA_BR_GC_TIMER
:
496 case QEMU_IFLA_BR_TOPOLOGY_CHANGE_TIMER
:
497 case QEMU_IFLA_BR_MCAST_LAST_MEMBER_INTVL
:
498 case QEMU_IFLA_BR_MCAST_MEMBERSHIP_INTVL
:
499 case QEMU_IFLA_BR_MCAST_QUERIER_INTVL
:
500 case QEMU_IFLA_BR_MCAST_QUERY_INTVL
:
501 case QEMU_IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
:
502 case QEMU_IFLA_BR_MCAST_STARTUP_QUERY_INTVL
:
503 u64
= NLA_DATA(nlattr
);
504 *u64
= tswap64(*u64
);
506 /* ifla_bridge_id: uin8_t[] */
507 case QEMU_IFLA_BR_ROOT_ID
:
508 case QEMU_IFLA_BR_BRIDGE_ID
:
510 /* br_boolopt_multi { uint32_t, uint32_t } */
511 case QEMU_IFLA_BR_MULTI_BOOLOPT
:
512 u32
= NLA_DATA(nlattr
);
513 u32
[0] = tswap32(u32
[0]); /* optval */
514 u32
[1] = tswap32(u32
[1]); /* optmask */
517 qemu_log_mask(LOG_UNIMP
, "Unknown QEMU_IFLA_BR type %d\n",
524 static abi_long
host_to_target_slave_data_bridge_nlattr(struct nlattr
*nlattr
,
531 switch (nlattr
->nla_type
) {
533 case QEMU_IFLA_BRPORT_STATE
:
534 case QEMU_IFLA_BRPORT_MODE
:
535 case QEMU_IFLA_BRPORT_GUARD
:
536 case QEMU_IFLA_BRPORT_PROTECT
:
537 case QEMU_IFLA_BRPORT_FAST_LEAVE
:
538 case QEMU_IFLA_BRPORT_LEARNING
:
539 case QEMU_IFLA_BRPORT_UNICAST_FLOOD
:
540 case QEMU_IFLA_BRPORT_PROXYARP
:
541 case QEMU_IFLA_BRPORT_LEARNING_SYNC
:
542 case QEMU_IFLA_BRPORT_PROXYARP_WIFI
:
543 case QEMU_IFLA_BRPORT_TOPOLOGY_CHANGE_ACK
:
544 case QEMU_IFLA_BRPORT_CONFIG_PENDING
:
545 case QEMU_IFLA_BRPORT_MULTICAST_ROUTER
:
546 case QEMU_IFLA_BRPORT_MCAST_FLOOD
:
547 case QEMU_IFLA_BRPORT_MCAST_TO_UCAST
:
548 case QEMU_IFLA_BRPORT_VLAN_TUNNEL
:
549 case QEMU_IFLA_BRPORT_BCAST_FLOOD
:
550 case QEMU_IFLA_BRPORT_NEIGH_SUPPRESS
:
551 case QEMU_IFLA_BRPORT_ISOLATED
:
554 case QEMU_IFLA_BRPORT_PRIORITY
:
555 case QEMU_IFLA_BRPORT_DESIGNATED_PORT
:
556 case QEMU_IFLA_BRPORT_DESIGNATED_COST
:
557 case QEMU_IFLA_BRPORT_ID
:
558 case QEMU_IFLA_BRPORT_NO
:
559 case QEMU_IFLA_BRPORT_GROUP_FWD_MASK
:
560 u16
= NLA_DATA(nlattr
);
561 *u16
= tswap16(*u16
);
564 case QEMU_IFLA_BRPORT_COST
:
565 case QEMU_IFLA_BRPORT_BACKUP_PORT
:
566 u32
= NLA_DATA(nlattr
);
567 *u32
= tswap32(*u32
);
570 case QEMU_IFLA_BRPORT_MESSAGE_AGE_TIMER
:
571 case QEMU_IFLA_BRPORT_FORWARD_DELAY_TIMER
:
572 case QEMU_IFLA_BRPORT_HOLD_TIMER
:
573 u64
= NLA_DATA(nlattr
);
574 *u64
= tswap64(*u64
);
576 /* ifla_bridge_id: uint8_t[] */
577 case QEMU_IFLA_BRPORT_ROOT_ID
:
578 case QEMU_IFLA_BRPORT_BRIDGE_ID
:
581 qemu_log_mask(LOG_UNIMP
, "Unknown QEMU_IFLA_BRPORT type %d\n",
588 static abi_long
host_to_target_data_tun_nlattr(struct nlattr
*nlattr
,
593 switch (nlattr
->nla_type
) {
595 case QEMU_IFLA_TUN_TYPE
:
596 case QEMU_IFLA_TUN_PI
:
597 case QEMU_IFLA_TUN_VNET_HDR
:
598 case QEMU_IFLA_TUN_PERSIST
:
599 case QEMU_IFLA_TUN_MULTI_QUEUE
:
602 case QEMU_IFLA_TUN_NUM_QUEUES
:
603 case QEMU_IFLA_TUN_NUM_DISABLED_QUEUES
:
604 case QEMU_IFLA_TUN_OWNER
:
605 case QEMU_IFLA_TUN_GROUP
:
606 u32
= NLA_DATA(nlattr
);
607 *u32
= tswap32(*u32
);
610 qemu_log_mask(LOG_UNIMP
, "Unknown QEMU_IFLA_TUN type %d\n",
617 struct linkinfo_context
{
624 static abi_long
host_to_target_data_linkinfo_nlattr(struct nlattr
*nlattr
,
627 struct linkinfo_context
*li_context
= context
;
629 switch (nlattr
->nla_type
) {
631 case QEMU_IFLA_INFO_KIND
:
632 li_context
->name
= NLA_DATA(nlattr
);
633 li_context
->len
= nlattr
->nla_len
- NLA_HDRLEN
;
635 case QEMU_IFLA_INFO_SLAVE_KIND
:
636 li_context
->slave_name
= NLA_DATA(nlattr
);
637 li_context
->slave_len
= nlattr
->nla_len
- NLA_HDRLEN
;
640 case QEMU_IFLA_INFO_XSTATS
:
641 /* FIXME: only used by CAN */
644 case QEMU_IFLA_INFO_DATA
:
645 if (strncmp(li_context
->name
, "bridge",
646 li_context
->len
) == 0) {
647 return host_to_target_for_each_nlattr(NLA_DATA(nlattr
),
650 host_to_target_data_bridge_nlattr
);
651 } else if (strncmp(li_context
->name
, "tun",
652 li_context
->len
) == 0) {
653 return host_to_target_for_each_nlattr(NLA_DATA(nlattr
),
656 host_to_target_data_tun_nlattr
);
658 qemu_log_mask(LOG_UNIMP
, "Unknown QEMU_IFLA_INFO_KIND %s\n",
662 case QEMU_IFLA_INFO_SLAVE_DATA
:
663 if (strncmp(li_context
->slave_name
, "bridge",
664 li_context
->slave_len
) == 0) {
665 return host_to_target_for_each_nlattr(NLA_DATA(nlattr
),
668 host_to_target_slave_data_bridge_nlattr
);
670 qemu_log_mask(LOG_UNIMP
, "Unknown QEMU_IFLA_INFO_SLAVE_KIND %s\n",
671 li_context
->slave_name
);
675 qemu_log_mask(LOG_UNIMP
, "Unknown host QEMU_IFLA_INFO type: %d\n",
683 static abi_long
host_to_target_data_inet_nlattr(struct nlattr
*nlattr
,
689 switch (nlattr
->nla_type
) {
690 case QEMU_IFLA_INET_CONF
:
691 u32
= NLA_DATA(nlattr
);
692 for (i
= 0; i
< (nlattr
->nla_len
- NLA_HDRLEN
) / sizeof(*u32
);
694 u32
[i
] = tswap32(u32
[i
]);
698 qemu_log_mask(LOG_UNIMP
, "Unknown host AF_INET type: %d\n",
704 static abi_long
host_to_target_data_inet6_nlattr(struct nlattr
*nlattr
,
709 struct ifla_cacheinfo
*ci
;
712 switch (nlattr
->nla_type
) {
714 case QEMU_IFLA_INET6_TOKEN
:
717 case QEMU_IFLA_INET6_ADDR_GEN_MODE
:
720 case QEMU_IFLA_INET6_FLAGS
:
721 u32
= NLA_DATA(nlattr
);
722 *u32
= tswap32(*u32
);
725 case QEMU_IFLA_INET6_CONF
:
726 u32
= NLA_DATA(nlattr
);
727 for (i
= 0; i
< (nlattr
->nla_len
- NLA_HDRLEN
) / sizeof(*u32
);
729 u32
[i
] = tswap32(u32
[i
]);
733 case QEMU_IFLA_INET6_CACHEINFO
:
734 ci
= NLA_DATA(nlattr
);
735 ci
->max_reasm_len
= tswap32(ci
->max_reasm_len
);
736 ci
->tstamp
= tswap32(ci
->tstamp
);
737 ci
->reachable_time
= tswap32(ci
->reachable_time
);
738 ci
->retrans_time
= tswap32(ci
->retrans_time
);
741 case QEMU_IFLA_INET6_STATS
:
742 case QEMU_IFLA_INET6_ICMP6STATS
:
743 u64
= NLA_DATA(nlattr
);
744 for (i
= 0; i
< (nlattr
->nla_len
- NLA_HDRLEN
) / sizeof(*u64
);
746 u64
[i
] = tswap64(u64
[i
]);
750 qemu_log_mask(LOG_UNIMP
, "Unknown host AF_INET6 type: %d\n",
756 static abi_long
host_to_target_data_spec_nlattr(struct nlattr
*nlattr
,
759 switch (nlattr
->nla_type
) {
761 return host_to_target_for_each_nlattr(NLA_DATA(nlattr
), nlattr
->nla_len
,
763 host_to_target_data_inet_nlattr
);
765 return host_to_target_for_each_nlattr(NLA_DATA(nlattr
), nlattr
->nla_len
,
767 host_to_target_data_inet6_nlattr
);
769 qemu_log_mask(LOG_UNIMP
, "Unknown host AF_SPEC type: %d\n",
776 static abi_long
host_to_target_data_xdp_nlattr(struct nlattr
*nlattr
,
781 switch (nlattr
->nla_type
) {
783 case QEMU_IFLA_XDP_ATTACHED
:
786 case QEMU_IFLA_XDP_PROG_ID
:
787 u32
= NLA_DATA(nlattr
);
788 *u32
= tswap32(*u32
);
792 LOG_UNIMP
, "Unknown host XDP type: %d\n", nlattr
->nla_type
);
798 static abi_long
host_to_target_data_link_rtattr(struct rtattr
*rtattr
)
801 struct rtnl_link_stats
*st
;
802 struct rtnl_link_stats64
*st64
;
803 struct rtnl_link_ifmap
*map
;
804 struct linkinfo_context li_context
;
806 switch (rtattr
->rta_type
) {
808 case QEMU_IFLA_ADDRESS
:
809 case QEMU_IFLA_BROADCAST
:
811 case QEMU_IFLA_IFNAME
:
812 case QEMU_IFLA_QDISC
:
815 case QEMU_IFLA_OPERSTATE
:
816 case QEMU_IFLA_LINKMODE
:
817 case QEMU_IFLA_CARRIER
:
818 case QEMU_IFLA_PROTO_DOWN
:
823 case QEMU_IFLA_WEIGHT
:
824 case QEMU_IFLA_TXQLEN
:
825 case QEMU_IFLA_CARRIER_CHANGES
:
826 case QEMU_IFLA_NUM_RX_QUEUES
:
827 case QEMU_IFLA_NUM_TX_QUEUES
:
828 case QEMU_IFLA_PROMISCUITY
:
829 case QEMU_IFLA_EXT_MASK
:
830 case QEMU_IFLA_LINK_NETNSID
:
831 case QEMU_IFLA_GROUP
:
832 case QEMU_IFLA_MASTER
:
833 case QEMU_IFLA_NUM_VF
:
834 case QEMU_IFLA_GSO_MAX_SEGS
:
835 case QEMU_IFLA_GSO_MAX_SIZE
:
836 case QEMU_IFLA_CARRIER_UP_COUNT
:
837 case QEMU_IFLA_CARRIER_DOWN_COUNT
:
838 case QEMU_IFLA_MIN_MTU
:
839 case QEMU_IFLA_MAX_MTU
:
840 u32
= RTA_DATA(rtattr
);
841 *u32
= tswap32(*u32
);
843 /* struct rtnl_link_stats */
844 case QEMU_IFLA_STATS
:
845 st
= RTA_DATA(rtattr
);
846 st
->rx_packets
= tswap32(st
->rx_packets
);
847 st
->tx_packets
= tswap32(st
->tx_packets
);
848 st
->rx_bytes
= tswap32(st
->rx_bytes
);
849 st
->tx_bytes
= tswap32(st
->tx_bytes
);
850 st
->rx_errors
= tswap32(st
->rx_errors
);
851 st
->tx_errors
= tswap32(st
->tx_errors
);
852 st
->rx_dropped
= tswap32(st
->rx_dropped
);
853 st
->tx_dropped
= tswap32(st
->tx_dropped
);
854 st
->multicast
= tswap32(st
->multicast
);
855 st
->collisions
= tswap32(st
->collisions
);
857 /* detailed rx_errors: */
858 st
->rx_length_errors
= tswap32(st
->rx_length_errors
);
859 st
->rx_over_errors
= tswap32(st
->rx_over_errors
);
860 st
->rx_crc_errors
= tswap32(st
->rx_crc_errors
);
861 st
->rx_frame_errors
= tswap32(st
->rx_frame_errors
);
862 st
->rx_fifo_errors
= tswap32(st
->rx_fifo_errors
);
863 st
->rx_missed_errors
= tswap32(st
->rx_missed_errors
);
865 /* detailed tx_errors */
866 st
->tx_aborted_errors
= tswap32(st
->tx_aborted_errors
);
867 st
->tx_carrier_errors
= tswap32(st
->tx_carrier_errors
);
868 st
->tx_fifo_errors
= tswap32(st
->tx_fifo_errors
);
869 st
->tx_heartbeat_errors
= tswap32(st
->tx_heartbeat_errors
);
870 st
->tx_window_errors
= tswap32(st
->tx_window_errors
);
873 st
->rx_compressed
= tswap32(st
->rx_compressed
);
874 st
->tx_compressed
= tswap32(st
->tx_compressed
);
876 /* struct rtnl_link_stats64 */
877 case QEMU_IFLA_STATS64
:
878 st64
= RTA_DATA(rtattr
);
879 st64
->rx_packets
= tswap64(st64
->rx_packets
);
880 st64
->tx_packets
= tswap64(st64
->tx_packets
);
881 st64
->rx_bytes
= tswap64(st64
->rx_bytes
);
882 st64
->tx_bytes
= tswap64(st64
->tx_bytes
);
883 st64
->rx_errors
= tswap64(st64
->rx_errors
);
884 st64
->tx_errors
= tswap64(st64
->tx_errors
);
885 st64
->rx_dropped
= tswap64(st64
->rx_dropped
);
886 st64
->tx_dropped
= tswap64(st64
->tx_dropped
);
887 st64
->multicast
= tswap64(st64
->multicast
);
888 st64
->collisions
= tswap64(st64
->collisions
);
890 /* detailed rx_errors: */
891 st64
->rx_length_errors
= tswap64(st64
->rx_length_errors
);
892 st64
->rx_over_errors
= tswap64(st64
->rx_over_errors
);
893 st64
->rx_crc_errors
= tswap64(st64
->rx_crc_errors
);
894 st64
->rx_frame_errors
= tswap64(st64
->rx_frame_errors
);
895 st64
->rx_fifo_errors
= tswap64(st64
->rx_fifo_errors
);
896 st64
->rx_missed_errors
= tswap64(st64
->rx_missed_errors
);
898 /* detailed tx_errors */
899 st64
->tx_aborted_errors
= tswap64(st64
->tx_aborted_errors
);
900 st64
->tx_carrier_errors
= tswap64(st64
->tx_carrier_errors
);
901 st64
->tx_fifo_errors
= tswap64(st64
->tx_fifo_errors
);
902 st64
->tx_heartbeat_errors
= tswap64(st64
->tx_heartbeat_errors
);
903 st64
->tx_window_errors
= tswap64(st64
->tx_window_errors
);
906 st64
->rx_compressed
= tswap64(st64
->rx_compressed
);
907 st64
->tx_compressed
= tswap64(st64
->tx_compressed
);
909 /* struct rtnl_link_ifmap */
911 map
= RTA_DATA(rtattr
);
912 map
->mem_start
= tswap64(map
->mem_start
);
913 map
->mem_end
= tswap64(map
->mem_end
);
914 map
->base_addr
= tswap64(map
->base_addr
);
915 map
->irq
= tswap16(map
->irq
);
918 case QEMU_IFLA_LINKINFO
:
919 memset(&li_context
, 0, sizeof(li_context
));
920 return host_to_target_for_each_nlattr(RTA_DATA(rtattr
), rtattr
->rta_len
,
922 host_to_target_data_linkinfo_nlattr
);
923 case QEMU_IFLA_AF_SPEC
:
924 return host_to_target_for_each_nlattr(RTA_DATA(rtattr
), rtattr
->rta_len
,
926 host_to_target_data_spec_nlattr
);
928 return host_to_target_for_each_nlattr(RTA_DATA(rtattr
), rtattr
->rta_len
,
930 host_to_target_data_xdp_nlattr
);
932 qemu_log_mask(LOG_UNIMP
, "Unknown host QEMU_IFLA type: %d\n",
939 static abi_long
host_to_target_data_addr_rtattr(struct rtattr
*rtattr
)
942 struct ifa_cacheinfo
*ci
;
944 switch (rtattr
->rta_type
) {
945 /* binary: depends on family type */
955 u32
= RTA_DATA(rtattr
);
956 *u32
= tswap32(*u32
);
958 /* struct ifa_cacheinfo */
960 ci
= RTA_DATA(rtattr
);
961 ci
->ifa_prefered
= tswap32(ci
->ifa_prefered
);
962 ci
->ifa_valid
= tswap32(ci
->ifa_valid
);
963 ci
->cstamp
= tswap32(ci
->cstamp
);
964 ci
->tstamp
= tswap32(ci
->tstamp
);
968 LOG_UNIMP
, "Unknown host IFA type: %d\n", rtattr
->rta_type
);
974 static abi_long
host_to_target_data_route_rtattr(struct rtattr
*rtattr
)
977 struct rta_cacheinfo
*ci
;
979 switch (rtattr
->rta_type
) {
980 /* binary: depends on family type */
981 case QEMU_RTA_GATEWAY
:
983 case QEMU_RTA_PREFSRC
:
989 case QEMU_RTA_PRIORITY
:
992 u32
= RTA_DATA(rtattr
);
993 *u32
= tswap32(*u32
);
995 /* struct rta_cacheinfo */
996 case QEMU_RTA_CACHEINFO
:
997 ci
= RTA_DATA(rtattr
);
998 ci
->rta_clntref
= tswap32(ci
->rta_clntref
);
999 ci
->rta_lastuse
= tswap32(ci
->rta_lastuse
);
1000 ci
->rta_expires
= tswap32(ci
->rta_expires
);
1001 ci
->rta_error
= tswap32(ci
->rta_error
);
1002 ci
->rta_used
= tswap32(ci
->rta_used
);
1003 #if defined(RTNETLINK_HAVE_PEERINFO)
1004 ci
->rta_id
= tswap32(ci
->rta_id
);
1005 ci
->rta_ts
= tswap32(ci
->rta_ts
);
1006 ci
->rta_tsage
= tswap32(ci
->rta_tsage
);
1011 LOG_UNIMP
, "Unknown host RTA type: %d\n", rtattr
->rta_type
);
1017 static abi_long
host_to_target_link_rtattr(struct rtattr
*rtattr
,
1018 uint32_t rtattr_len
)
1020 return host_to_target_for_each_rtattr(rtattr
, rtattr_len
,
1021 host_to_target_data_link_rtattr
);
1024 static abi_long
host_to_target_addr_rtattr(struct rtattr
*rtattr
,
1025 uint32_t rtattr_len
)
1027 return host_to_target_for_each_rtattr(rtattr
, rtattr_len
,
1028 host_to_target_data_addr_rtattr
);
1031 static abi_long
host_to_target_route_rtattr(struct rtattr
*rtattr
,
1032 uint32_t rtattr_len
)
1034 return host_to_target_for_each_rtattr(rtattr
, rtattr_len
,
1035 host_to_target_data_route_rtattr
);
1038 static abi_long
host_to_target_data_route(struct nlmsghdr
*nlh
)
1041 struct ifinfomsg
*ifi
;
1042 struct ifaddrmsg
*ifa
;
1045 nlmsg_len
= nlh
->nlmsg_len
;
1046 switch (nlh
->nlmsg_type
) {
1050 if (nlh
->nlmsg_len
>= NLMSG_LENGTH(sizeof(*ifi
))) {
1051 ifi
= NLMSG_DATA(nlh
);
1052 ifi
->ifi_type
= tswap16(ifi
->ifi_type
);
1053 ifi
->ifi_index
= tswap32(ifi
->ifi_index
);
1054 ifi
->ifi_flags
= tswap32(ifi
->ifi_flags
);
1055 ifi
->ifi_change
= tswap32(ifi
->ifi_change
);
1056 host_to_target_link_rtattr(IFLA_RTA(ifi
),
1057 nlmsg_len
- NLMSG_LENGTH(sizeof(*ifi
)));
1063 if (nlh
->nlmsg_len
>= NLMSG_LENGTH(sizeof(*ifa
))) {
1064 ifa
= NLMSG_DATA(nlh
);
1065 ifa
->ifa_index
= tswap32(ifa
->ifa_index
);
1066 host_to_target_addr_rtattr(IFA_RTA(ifa
),
1067 nlmsg_len
- NLMSG_LENGTH(sizeof(*ifa
)));
1073 if (nlh
->nlmsg_len
>= NLMSG_LENGTH(sizeof(*rtm
))) {
1074 rtm
= NLMSG_DATA(nlh
);
1075 rtm
->rtm_flags
= tswap32(rtm
->rtm_flags
);
1076 host_to_target_route_rtattr(RTM_RTA(rtm
),
1077 nlmsg_len
- NLMSG_LENGTH(sizeof(*rtm
)));
1081 return -TARGET_EINVAL
;
1086 static inline abi_long
host_to_target_nlmsg_route(struct nlmsghdr
*nlh
,
1089 return host_to_target_for_each_nlmsg(nlh
, len
, host_to_target_data_route
);
1092 static abi_long
target_to_host_for_each_rtattr(struct rtattr
*rtattr
,
1094 abi_long (*target_to_host_rtattr
)
1097 unsigned short aligned_rta_len
;
1100 while (len
>= sizeof(struct rtattr
)) {
1101 if (tswap16(rtattr
->rta_len
) < sizeof(struct rtattr
) ||
1102 tswap16(rtattr
->rta_len
) > len
) {
1105 rtattr
->rta_len
= tswap16(rtattr
->rta_len
);
1106 rtattr
->rta_type
= tswap16(rtattr
->rta_type
);
1107 ret
= target_to_host_rtattr(rtattr
);
1112 aligned_rta_len
= RTA_ALIGN(rtattr
->rta_len
);
1113 if (aligned_rta_len
>= len
) {
1116 len
-= aligned_rta_len
;
1117 rtattr
= (struct rtattr
*)(((char *)rtattr
) + aligned_rta_len
);
1122 static abi_long
target_to_host_data_link_rtattr(struct rtattr
*rtattr
)
1124 switch (rtattr
->rta_type
) {
1126 qemu_log_mask(LOG_UNIMP
, "Unknown target QEMU_IFLA type: %d\n",
1133 static abi_long
target_to_host_data_addr_rtattr(struct rtattr
*rtattr
)
1135 switch (rtattr
->rta_type
) {
1136 /* binary: depends on family type */
1141 qemu_log_mask(LOG_UNIMP
, "Unknown target IFA type: %d\n",
1148 static abi_long
target_to_host_data_route_rtattr(struct rtattr
*rtattr
)
1151 switch (rtattr
->rta_type
) {
1152 /* binary: depends on family type */
1155 case QEMU_RTA_GATEWAY
:
1158 case QEMU_RTA_PRIORITY
:
1160 u32
= RTA_DATA(rtattr
);
1161 *u32
= tswap32(*u32
);
1164 qemu_log_mask(LOG_UNIMP
, "Unknown target RTA type: %d\n",
1171 static void target_to_host_link_rtattr(struct rtattr
*rtattr
,
1172 uint32_t rtattr_len
)
1174 target_to_host_for_each_rtattr(rtattr
, rtattr_len
,
1175 target_to_host_data_link_rtattr
);
1178 static void target_to_host_addr_rtattr(struct rtattr
*rtattr
,
1179 uint32_t rtattr_len
)
1181 target_to_host_for_each_rtattr(rtattr
, rtattr_len
,
1182 target_to_host_data_addr_rtattr
);
1185 static void target_to_host_route_rtattr(struct rtattr
*rtattr
,
1186 uint32_t rtattr_len
)
1188 target_to_host_for_each_rtattr(rtattr
, rtattr_len
,
1189 target_to_host_data_route_rtattr
);
1192 static abi_long
target_to_host_data_route(struct nlmsghdr
*nlh
)
1194 struct ifinfomsg
*ifi
;
1195 struct ifaddrmsg
*ifa
;
1198 switch (nlh
->nlmsg_type
) {
1203 if (nlh
->nlmsg_len
>= NLMSG_LENGTH(sizeof(*ifi
))) {
1204 ifi
= NLMSG_DATA(nlh
);
1205 ifi
->ifi_type
= tswap16(ifi
->ifi_type
);
1206 ifi
->ifi_index
= tswap32(ifi
->ifi_index
);
1207 ifi
->ifi_flags
= tswap32(ifi
->ifi_flags
);
1208 ifi
->ifi_change
= tswap32(ifi
->ifi_change
);
1209 target_to_host_link_rtattr(IFLA_RTA(ifi
), nlh
->nlmsg_len
-
1210 NLMSG_LENGTH(sizeof(*ifi
)));
1216 if (nlh
->nlmsg_len
>= NLMSG_LENGTH(sizeof(*ifa
))) {
1217 ifa
= NLMSG_DATA(nlh
);
1218 ifa
->ifa_index
= tswap32(ifa
->ifa_index
);
1219 target_to_host_addr_rtattr(IFA_RTA(ifa
), nlh
->nlmsg_len
-
1220 NLMSG_LENGTH(sizeof(*ifa
)));
1227 if (nlh
->nlmsg_len
>= NLMSG_LENGTH(sizeof(*rtm
))) {
1228 rtm
= NLMSG_DATA(nlh
);
1229 rtm
->rtm_flags
= tswap32(rtm
->rtm_flags
);
1230 target_to_host_route_rtattr(RTM_RTA(rtm
), nlh
->nlmsg_len
-
1231 NLMSG_LENGTH(sizeof(*rtm
)));
1235 return -TARGET_EOPNOTSUPP
;
1240 static abi_long
target_to_host_nlmsg_route(struct nlmsghdr
*nlh
, size_t len
)
1242 return target_to_host_for_each_nlmsg(nlh
, len
, target_to_host_data_route
);
1244 #endif /* CONFIG_RTNETLINK */
1246 static abi_long
host_to_target_data_audit(struct nlmsghdr
*nlh
)
1248 switch (nlh
->nlmsg_type
) {
1250 qemu_log_mask(LOG_UNIMP
, "Unknown host audit message type %d\n",
1252 return -TARGET_EINVAL
;
1257 static inline abi_long
host_to_target_nlmsg_audit(struct nlmsghdr
*nlh
,
1260 return host_to_target_for_each_nlmsg(nlh
, len
, host_to_target_data_audit
);
1263 static abi_long
target_to_host_data_audit(struct nlmsghdr
*nlh
)
1265 switch (nlh
->nlmsg_type
) {
1267 case AUDIT_FIRST_USER_MSG
... AUDIT_LAST_USER_MSG
:
1268 case AUDIT_FIRST_USER_MSG2
... AUDIT_LAST_USER_MSG2
:
1271 qemu_log_mask(LOG_UNIMP
, "Unknown target audit message type %d\n",
1273 return -TARGET_EINVAL
;
1279 static abi_long
target_to_host_nlmsg_audit(struct nlmsghdr
*nlh
, size_t len
)
1281 return target_to_host_for_each_nlmsg(nlh
, len
, target_to_host_data_audit
);
1284 static abi_long
packet_target_to_host_sockaddr(void *host_addr
,
1285 abi_ulong target_addr
,
1288 struct sockaddr
*addr
= host_addr
;
1289 struct target_sockaddr
*target_saddr
;
1291 target_saddr
= lock_user(VERIFY_READ
, target_addr
, len
, 1);
1292 if (!target_saddr
) {
1293 return -TARGET_EFAULT
;
1296 memcpy(addr
, target_saddr
, len
);
1297 addr
->sa_family
= tswap16(target_saddr
->sa_family
);
1298 /* spkt_protocol is big-endian */
1300 unlock_user(target_saddr
, target_addr
, 0);
1304 TargetFdTrans target_packet_trans
= {
1305 .target_to_host_addr
= packet_target_to_host_sockaddr
,
1308 #ifdef CONFIG_RTNETLINK
1309 static abi_long
netlink_route_target_to_host(void *buf
, size_t len
)
1313 ret
= target_to_host_nlmsg_route(buf
, len
);
1321 static abi_long
netlink_route_host_to_target(void *buf
, size_t len
)
1325 ret
= host_to_target_nlmsg_route(buf
, len
);
1333 TargetFdTrans target_netlink_route_trans
= {
1334 .target_to_host_data
= netlink_route_target_to_host
,
1335 .host_to_target_data
= netlink_route_host_to_target
,
1337 #endif /* CONFIG_RTNETLINK */
1339 static abi_long
netlink_audit_target_to_host(void *buf
, size_t len
)
1343 ret
= target_to_host_nlmsg_audit(buf
, len
);
1351 static abi_long
netlink_audit_host_to_target(void *buf
, size_t len
)
1355 ret
= host_to_target_nlmsg_audit(buf
, len
);
1363 TargetFdTrans target_netlink_audit_trans
= {
1364 .target_to_host_data
= netlink_audit_target_to_host
,
1365 .host_to_target_data
= netlink_audit_host_to_target
,
1368 /* signalfd siginfo conversion */
1371 host_to_target_signalfd_siginfo(struct signalfd_siginfo
*tinfo
,
1372 const struct signalfd_siginfo
*info
)
1374 int sig
= host_to_target_signal(info
->ssi_signo
);
1376 /* linux/signalfd.h defines a ssi_addr_lsb
1377 * not defined in sys/signalfd.h but used by some kernels
1380 #ifdef BUS_MCEERR_AO
1381 if (tinfo
->ssi_signo
== SIGBUS
&&
1382 (tinfo
->ssi_code
== BUS_MCEERR_AR
||
1383 tinfo
->ssi_code
== BUS_MCEERR_AO
)) {
1384 uint16_t *ssi_addr_lsb
= (uint16_t *)(&info
->ssi_addr
+ 1);
1385 uint16_t *tssi_addr_lsb
= (uint16_t *)(&tinfo
->ssi_addr
+ 1);
1386 *tssi_addr_lsb
= tswap16(*ssi_addr_lsb
);
1390 tinfo
->ssi_signo
= tswap32(sig
);
1391 tinfo
->ssi_errno
= tswap32(tinfo
->ssi_errno
);
1392 tinfo
->ssi_code
= tswap32(info
->ssi_code
);
1393 tinfo
->ssi_pid
= tswap32(info
->ssi_pid
);
1394 tinfo
->ssi_uid
= tswap32(info
->ssi_uid
);
1395 tinfo
->ssi_fd
= tswap32(info
->ssi_fd
);
1396 tinfo
->ssi_tid
= tswap32(info
->ssi_tid
);
1397 tinfo
->ssi_band
= tswap32(info
->ssi_band
);
1398 tinfo
->ssi_overrun
= tswap32(info
->ssi_overrun
);
1399 tinfo
->ssi_trapno
= tswap32(info
->ssi_trapno
);
1400 tinfo
->ssi_status
= tswap32(info
->ssi_status
);
1401 tinfo
->ssi_int
= tswap32(info
->ssi_int
);
1402 tinfo
->ssi_ptr
= tswap64(info
->ssi_ptr
);
1403 tinfo
->ssi_utime
= tswap64(info
->ssi_utime
);
1404 tinfo
->ssi_stime
= tswap64(info
->ssi_stime
);
1405 tinfo
->ssi_addr
= tswap64(info
->ssi_addr
);
1408 static abi_long
host_to_target_data_signalfd(void *buf
, size_t len
)
1412 for (i
= 0; i
< len
; i
+= sizeof(struct signalfd_siginfo
)) {
1413 host_to_target_signalfd_siginfo(buf
+ i
, buf
+ i
);
1419 TargetFdTrans target_signalfd_trans
= {
1420 .host_to_target_data
= host_to_target_data_signalfd
,
1423 static abi_long
swap_data_eventfd(void *buf
, size_t len
)
1425 uint64_t *counter
= buf
;
1428 if (len
< sizeof(uint64_t)) {
1432 for (i
= 0; i
< len
; i
+= sizeof(uint64_t)) {
1433 *counter
= tswap64(*counter
);
1440 TargetFdTrans target_eventfd_trans
= {
1441 .host_to_target_data
= swap_data_eventfd
,
1442 .target_to_host_data
= swap_data_eventfd
,
1445 #if (defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)) || \
1446 (defined(CONFIG_INOTIFY1) && defined(TARGET_NR_inotify_init1) && \
1447 defined(__NR_inotify_init1))
1448 static abi_long
host_to_target_data_inotify(void *buf
, size_t len
)
1450 struct inotify_event
*ev
;
1454 for (i
= 0; i
< len
; i
+= sizeof(struct inotify_event
) + name_len
) {
1455 ev
= (struct inotify_event
*)((char *)buf
+ i
);
1458 ev
->wd
= tswap32(ev
->wd
);
1459 ev
->mask
= tswap32(ev
->mask
);
1460 ev
->cookie
= tswap32(ev
->cookie
);
1461 ev
->len
= tswap32(name_len
);
1467 TargetFdTrans target_inotify_trans
= {
1468 .host_to_target_data
= host_to_target_data_inotify
,