qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>
To: qemu-devel@nongnu.org
Cc: aurelien@aurel32.net, amarkovic@wavecomp.com,
	arikalo@wavecomp.com, daniel.santos@pobox.com,
	jcmvbkbc@gmail.com, lvivier@redhat.com, thuth@redhat.com,
	philmd@redhat.com, Neng Chen <nchen@wavecomp.com>
Subject: [Qemu-devel] [PATCH v2 4/5] linux-user: setsockopt(): Add support for the option IPV6_ADD_MEMBERSHIP
Date: Wed, 24 Apr 2019 14:57:02 +0200	[thread overview]
Message-ID: <1556110623-655-5-git-send-email-aleksandar.markovic@rt-rk.com> (raw)
In-Reply-To: <1556110623-655-1-git-send-email-aleksandar.markovic@rt-rk.com>

From: Neng Chen <nchen@wavecomp.com>

Add support for the option IPV6_ADD_MEMBERSHIP of the syscall
setsockopt(). This option controls membership in multicast groups.
Argument is a pointer to a struct ipv6_mreq, which is in turn defined
in a platform-inedependant manner in the Linux kernel file
include/uapi/linux/in6.h as:

The <netinet/in.h> header defines the ipv6_mreq structure, which
includes the following members:

struct in6_addr ipv6mr_multiaddr  /* IPv6 multicast address   */
unsigned int    ipv6mr_interface  /* local interface index    */

struct ipv6_mreq {
    /* IPv6 multicast address of group */
    struct in6_addr  ipv6mr_multiaddr;

    /* local IPv6 address of interface */
    int              ipv6mr_ifindex;
};

The <netinet/in.h> header also defines the in6_addr structure,
which a union of the following structure:

struct in6_addr {
    union {
        __u8    u6_addr8[16];
        __be16  u6_addr16[8];
        __be32  u6_addr32[4];
    } in6_u;

The emulation behavior of IPV6_ADD_MEMBERSHIP is devised based on
the definitions above.

Signed-off-by: Neng Chen <nchen@wavecomp.com>
Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
---
 linux-user/syscall.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 96cd4bf..b47a45d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1892,6 +1892,24 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
                                        &pki, sizeof(pki)));
             break;
         }
+        case IPV6_ADD_MEMBERSHIP:
+        {
+            struct ipv6_mreq ipv6mreq;
+
+            if (optlen < sizeof(ipv6mreq)) {
+                return -TARGET_EINVAL;
+            }
+
+            if (copy_from_user(&ipv6mreq, optval_addr, sizeof(ipv6mreq))) {
+                return -TARGET_EFAULT;
+            }
+
+            ipv6mreq.ipv6mr_interface = tswap32(ipv6mreq.ipv6mr_interface);
+
+            ret = get_errno(setsockopt(sockfd, level, optname,
+                                       &ipv6mreq, sizeof(ipv6mreq)));
+            break;
+        }
         default:
             goto unimplemented;
         }
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>
To: qemu-devel@nongnu.org
Cc: lvivier@redhat.com, thuth@redhat.com, jcmvbkbc@gmail.com,
	arikalo@wavecomp.com, daniel.santos@pobox.com,
	amarkovic@wavecomp.com, Neng Chen <nchen@wavecomp.com>,
	philmd@redhat.com, aurelien@aurel32.net
Subject: [Qemu-devel] [PATCH v2 4/5] linux-user: setsockopt(): Add support for the option IPV6_ADD_MEMBERSHIP
Date: Wed, 24 Apr 2019 14:57:02 +0200	[thread overview]
Message-ID: <1556110623-655-5-git-send-email-aleksandar.markovic@rt-rk.com> (raw)
Message-ID: <20190424125702.1Ee9NqqSdK_lrAt2kSMqYMmbsjR8aDD3cLZmgGWi3ak@z> (raw)
In-Reply-To: <1556110623-655-1-git-send-email-aleksandar.markovic@rt-rk.com>

From: Neng Chen <nchen@wavecomp.com>

Add support for the option IPV6_ADD_MEMBERSHIP of the syscall
setsockopt(). This option controls membership in multicast groups.
Argument is a pointer to a struct ipv6_mreq, which is in turn defined
in a platform-inedependant manner in the Linux kernel file
include/uapi/linux/in6.h as:

The <netinet/in.h> header defines the ipv6_mreq structure, which
includes the following members:

struct in6_addr ipv6mr_multiaddr  /* IPv6 multicast address   */
unsigned int    ipv6mr_interface  /* local interface index    */

struct ipv6_mreq {
    /* IPv6 multicast address of group */
    struct in6_addr  ipv6mr_multiaddr;

    /* local IPv6 address of interface */
    int              ipv6mr_ifindex;
};

The <netinet/in.h> header also defines the in6_addr structure,
which a union of the following structure:

struct in6_addr {
    union {
        __u8    u6_addr8[16];
        __be16  u6_addr16[8];
        __be32  u6_addr32[4];
    } in6_u;

The emulation behavior of IPV6_ADD_MEMBERSHIP is devised based on
the definitions above.

Signed-off-by: Neng Chen <nchen@wavecomp.com>
Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
---
 linux-user/syscall.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 96cd4bf..b47a45d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1892,6 +1892,24 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
                                        &pki, sizeof(pki)));
             break;
         }
+        case IPV6_ADD_MEMBERSHIP:
+        {
+            struct ipv6_mreq ipv6mreq;
+
+            if (optlen < sizeof(ipv6mreq)) {
+                return -TARGET_EINVAL;
+            }
+
+            if (copy_from_user(&ipv6mreq, optval_addr, sizeof(ipv6mreq))) {
+                return -TARGET_EFAULT;
+            }
+
+            ipv6mreq.ipv6mr_interface = tswap32(ipv6mreq.ipv6mr_interface);
+
+            ret = get_errno(setsockopt(sockfd, level, optname,
+                                       &ipv6mreq, sizeof(ipv6mreq)));
+            break;
+        }
         default:
             goto unimplemented;
         }
-- 
2.7.4



  parent reply	other threads:[~2019-04-24 12:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-24 12:56 [Qemu-devel] [PATCH v2 0/5] linux-user: A set of misc patches for 4.1 Aleksandar Markovic
2019-04-24 12:56 ` Aleksandar Markovic
2019-04-24 12:56 ` [Qemu-devel] [PATCH v2 1/5] linux-user: Fix support for the SIOCATMARK and SIOCGPGRP ioctls for eXtensa Aleksandar Markovic
2019-04-24 12:56   ` Aleksandar Markovic
2019-04-24 13:03   ` Aleksandar Markovic
2019-04-24 13:03     ` Aleksandar Markovic
2019-04-26  5:10   ` Max Filippov
2019-04-26  5:10     ` Max Filippov
2019-04-24 12:57 ` [Qemu-devel] [PATCH v2 2/5] linux-user: Add support for the SIOCSPGRP ioctl Aleksandar Markovic
2019-04-24 12:57   ` Aleksandar Markovic
2019-04-26  5:14   ` Max Filippov
2019-04-26  5:14     ` Max Filippov
2019-04-24 12:57 ` [Qemu-devel] [PATCH v2 3/5] linux-user: Add support the SIOCSIFPFLAGS and SIOCGIFPFLAGS ioctls Aleksandar Markovic
2019-04-24 12:57   ` Aleksandar Markovic
2019-04-24 12:57 ` Aleksandar Markovic [this message]
2019-04-24 12:57   ` [Qemu-devel] [PATCH v2 4/5] linux-user: setsockopt(): Add support for the option IPV6_ADD_MEMBERSHIP Aleksandar Markovic
2019-04-24 13:52   ` Aleksandar Markovic
2019-04-24 13:52     ` Aleksandar Markovic
2019-04-24 12:57 ` [Qemu-devel] [PATCH v2 5/5] linux-user: Sanitize interp_info and, for mips only, init field fp_abi Aleksandar Markovic
2019-04-24 12:57   ` Aleksandar Markovic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1556110623-655-5-git-send-email-aleksandar.markovic@rt-rk.com \
    --to=aleksandar.markovic@rt-rk.com \
    --cc=amarkovic@wavecomp.com \
    --cc=arikalo@wavecomp.com \
    --cc=aurelien@aurel32.net \
    --cc=daniel.santos@pobox.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=lvivier@redhat.com \
    --cc=nchen@wavecomp.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).