Message ID | 1405172827-30693-1-git-send-email-Joakim.Tjernlund@transmode.se |
---|---|
State | New |
Headers | show |
On 12 July 2014 14:47, Joakim Tjernlund <Joakim.Tjernlund@transmode.se> wrote: [cc'ing Riku who's the linux-user maintainer.] > Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> > --- > linux-user/syscall.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > index 57c1664..3ef046a 100644 > --- a/linux-user/syscall.c > +++ b/linux-user/syscall.c > @@ -1497,6 +1497,25 @@ set_timeout: > unlock_user_struct(tfprog, optval_addr, 1); > return ret; > } > + case TARGET_SO_BINDTODEVICE: > + { > + char *dev_ifname, *addr_ifname; > + > + if (optlen > IFNAMSIZ - 1) { > + optlen = IFNAMSIZ - 1; > + } > + dev_ifname = lock_user(VERIFY_READ, optval_addr, optlen, 1); > + if (!dev_ifname) { > + return -TARGET_EFAULT; > + } > + optname = SO_BINDTODEVICE; > + addr_ifname = alloca(IFNAMSIZ); > + memcpy(addr_ifname, dev_ifname, optlen); > + addr_ifname[optlen] = 0; > + ret = get_errno(setsockopt(sockfd, level, optname, addr_ifname, optlen)); > + unlock_user (dev_ifname, optval_addr, 0); > + return ret; > + } > /* Options with 'int' argument. */ > case TARGET_SO_DEBUG: > optname = SO_DEBUG; > -- > 1.8.5.5 Reviewed-by: Peter Maydell <peter.maydell@linaro.org> thanks -- PMM
On Sat, Jul 12, 2014 at 03:47:06PM +0200, Joakim Tjernlund wrote: > Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Thanks, applied to linux-user tree, Riku > --- > linux-user/syscall.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > index 57c1664..3ef046a 100644 > --- a/linux-user/syscall.c > +++ b/linux-user/syscall.c > @@ -1497,6 +1497,25 @@ set_timeout: > unlock_user_struct(tfprog, optval_addr, 1); > return ret; > } > + case TARGET_SO_BINDTODEVICE: > + { > + char *dev_ifname, *addr_ifname; > + > + if (optlen > IFNAMSIZ - 1) { > + optlen = IFNAMSIZ - 1; > + } > + dev_ifname = lock_user(VERIFY_READ, optval_addr, optlen, 1); > + if (!dev_ifname) { > + return -TARGET_EFAULT; > + } > + optname = SO_BINDTODEVICE; > + addr_ifname = alloca(IFNAMSIZ); > + memcpy(addr_ifname, dev_ifname, optlen); > + addr_ifname[optlen] = 0; > + ret = get_errno(setsockopt(sockfd, level, optname, addr_ifname, optlen)); > + unlock_user (dev_ifname, optval_addr, 0); > + return ret; > + } > /* Options with 'int' argument. */ > case TARGET_SO_DEBUG: > optname = SO_DEBUG; > -- > 1.8.5.5 >
diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 57c1664..3ef046a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1497,6 +1497,25 @@ set_timeout: unlock_user_struct(tfprog, optval_addr, 1); return ret; } + case TARGET_SO_BINDTODEVICE: + { + char *dev_ifname, *addr_ifname; + + if (optlen > IFNAMSIZ - 1) { + optlen = IFNAMSIZ - 1; + } + dev_ifname = lock_user(VERIFY_READ, optval_addr, optlen, 1); + if (!dev_ifname) { + return -TARGET_EFAULT; + } + optname = SO_BINDTODEVICE; + addr_ifname = alloca(IFNAMSIZ); + memcpy(addr_ifname, dev_ifname, optlen); + addr_ifname[optlen] = 0; + ret = get_errno(setsockopt(sockfd, level, optname, addr_ifname, optlen)); + unlock_user (dev_ifname, optval_addr, 0); + return ret; + } /* Options with 'int' argument. */ case TARGET_SO_DEBUG: optname = SO_DEBUG;
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> --- linux-user/syscall.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)