diff options
Diffstat (limited to 'drivers/staging/usbip')
-rw-r--r-- | drivers/staging/usbip/stub_dev.c | 26 | ||||
-rw-r--r-- | drivers/staging/usbip/stub_main.c | 4 | ||||
-rw-r--r-- | drivers/staging/usbip/userspace/configure.ac | 1 | ||||
-rw-r--r-- | drivers/staging/usbip/userspace/doc/usbip.8 | 8 | ||||
-rw-r--r-- | drivers/staging/usbip/userspace/doc/usbipd.8 | 27 | ||||
-rw-r--r-- | drivers/staging/usbip/userspace/src/usbip_network.c | 16 | ||||
-rw-r--r-- | drivers/staging/usbip/userspace/src/usbip_network.h | 1 | ||||
-rw-r--r-- | drivers/staging/usbip/userspace/src/usbipd.c | 69 | ||||
-rw-r--r-- | drivers/staging/usbip/vhci_hcd.c | 10 |
9 files changed, 120 insertions, 42 deletions
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index d8957a5..76a1ff0 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -357,8 +357,9 @@ static int stub_probe(struct usb_interface *interface, busid_priv = get_busid_priv(udev_busid); if (!busid_priv || (busid_priv->status == STUB_BUSID_REMOV) || (busid_priv->status == STUB_BUSID_OTHER)) { - dev_info(&interface->dev, "%s is not in match_busid table... " - "skip!\n", udev_busid); + dev_info(&interface->dev, + "%s is not in match_busid table... skip!\n", + udev_busid); /* * Return value should be ENODEV or ENOXIO to continue trying @@ -375,8 +376,10 @@ static int stub_probe(struct usb_interface *interface, } if (!strcmp(udev->bus->bus_name, "vhci_hcd")) { - dev_dbg(&udev->dev, "%s is attached on vhci_hcd... skip!\n", - udev_busid); + dev_dbg(&udev->dev, + "%s is attached on vhci_hcd... skip!\n", + udev_busid); + return -ENODEV; } @@ -386,10 +389,10 @@ static int stub_probe(struct usb_interface *interface, return -ENODEV; busid_priv->interf_count++; - dev_info(&interface->dev, "usbip-host: register new interface " - "(bus %u dev %u ifn %u)\n", - udev->bus->busnum, udev->devnum, - interface->cur_altsetting->desc.bInterfaceNumber); + dev_info(&interface->dev, + "usbip-host: register new interface (bus %u dev %u ifn %u)\n", + udev->bus->busnum, udev->devnum, + interface->cur_altsetting->desc.bInterfaceNumber); /* set private data to usb_interface */ usb_set_intfdata(interface, sdev); @@ -412,9 +415,10 @@ static int stub_probe(struct usb_interface *interface, if (!sdev) return -ENOMEM; - dev_info(&interface->dev, "usbip-host: register new device " - "(bus %u dev %u ifn %u)\n", udev->bus->busnum, udev->devnum, - interface->cur_altsetting->desc.bInterfaceNumber); + dev_info(&interface->dev, + "usbip-host: register new device (bus %u dev %u ifn %u)\n", + udev->bus->busnum, udev->devnum, + interface->cur_altsetting->desc.bInterfaceNumber); busid_priv->interf_count = 0; busid_priv->shutdown_busid = 0; diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index 33027cc..baf857f 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -255,14 +255,14 @@ static int __init usbip_host_init(void) } ret = usb_register(&stub_driver); - if (ret < 0) { + if (ret) { pr_err("usb_register failed %d\n", ret); goto err_usb_register; } ret = driver_create_file(&stub_driver.drvwrap.driver, &driver_attr_match_busid); - if (ret < 0) { + if (ret) { pr_err("driver_create_file failed\n"); goto err_create_file; } diff --git a/drivers/staging/usbip/userspace/configure.ac b/drivers/staging/usbip/userspace/configure.ac index 2be4060..0ee5d92 100644 --- a/drivers/staging/usbip/userspace/configure.ac +++ b/drivers/staging/usbip/userspace/configure.ac @@ -70,7 +70,6 @@ AC_ARG_WITH([tcp-wrappers], [AC_MSG_RESULT([not found]); exit 1]) else AC_MSG_RESULT([no]); - LIBS="$saved_LIBS" fi], dnl [ACTION-IF-NOT-GIVEN] [AC_MSG_RESULT([(default)]) diff --git a/drivers/staging/usbip/userspace/doc/usbip.8 b/drivers/staging/usbip/userspace/doc/usbip.8 index ccdadc8..a6097be 100644 --- a/drivers/staging/usbip/userspace/doc/usbip.8 +++ b/drivers/staging/usbip/userspace/doc/usbip.8 @@ -3,7 +3,7 @@ usbip \- manage USB/IP devices .SH SYNOPSIS .B usbip -[\foptions\R] <\fIcommand\fR> <\fIargs\fR> +[\fIoptions\fR] <\fIcommand\fR> <\fIargs\fR> .SH DESCRIPTION On a USB/IP server, devices can be listed, bound, and unbound using @@ -23,6 +23,12 @@ Print debugging information. Log to syslog. .PP +.HP +\fB\-\-tcp-port PORT\fR +.IP +Connect to PORT on remote host (used for attach and list --remote). +.PP + .SH COMMANDS .HP \fBversion\fR diff --git a/drivers/staging/usbip/userspace/doc/usbipd.8 b/drivers/staging/usbip/userspace/doc/usbipd.8 index d896936..ac4635d 100644 --- a/drivers/staging/usbip/userspace/doc/usbipd.8 +++ b/drivers/staging/usbip/userspace/doc/usbipd.8 @@ -14,10 +14,22 @@ Devices have to explicitly be exported using before usbipd makes them available to other hosts. The daemon accepts connections from USB/IP clients -on TCP port 3240. +on TCP port 3240 by default. .SH OPTIONS .HP +\fB\-4\fR, \fB\-\-ipv4\fR +.IP +Bind to IPv4. Default is both. +.PP + +.HP +\fB\-6\fR, \fB\-\-ipv6\fR +.IP +Bind to IPv6. Default is both. +.PP + +.HP \fB\-D\fR, \fB\-\-daemon\fR .IP Run as a daemon process. @@ -29,6 +41,19 @@ Run as a daemon process. Print debugging information. .PP +.HP +\fB\-PFILE\fR, \fB\-\-pid FILE\fR +.IP +Write process id to FILE. +.br +If no FILE specified, use /var/run/usbipd.pid +.PP + +\fB\-tPORT\fR, \fB\-\-tcp\-port PORT\fR +.IP +Listen on TCP/IP port PORT. +.PP + \fB\-h\fR, \fB\-\-help\fR .IP Print the program help message and exit. diff --git a/drivers/staging/usbip/userspace/src/usbip_network.c b/drivers/staging/usbip/userspace/src/usbip_network.c index c39a07f..b4c37e7 100644 --- a/drivers/staging/usbip/userspace/src/usbip_network.c +++ b/drivers/staging/usbip/userspace/src/usbip_network.c @@ -25,6 +25,10 @@ #include <netinet/tcp.h> #include <unistd.h> +#ifdef HAVE_LIBWRAP +#include <tcpd.h> +#endif + #include "usbip_common.h" #include "usbip_network.h" @@ -239,6 +243,18 @@ int usbip_net_set_keepalive(int sockfd) return ret; } +int usbip_net_set_v6only(int sockfd) +{ + const int val = 1; + int ret; + + ret = setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val)); + if (ret < 0) + dbg("setsockopt: IPV6_V6ONLY"); + + return ret; +} + /* * IPv6 Ready */ diff --git a/drivers/staging/usbip/userspace/src/usbip_network.h b/drivers/staging/usbip/userspace/src/usbip_network.h index 2d0e427..f19ae19 100644 --- a/drivers/staging/usbip/userspace/src/usbip_network.h +++ b/drivers/staging/usbip/userspace/src/usbip_network.h @@ -180,6 +180,7 @@ int usbip_net_recv_op_common(int sockfd, uint16_t *code); int usbip_net_set_reuseaddr(int sockfd); int usbip_net_set_nodelay(int sockfd); int usbip_net_set_keepalive(int sockfd); +int usbip_net_set_v6only(int sockfd); int usbip_net_tcp_connect(char *hostname, char *port); #endif /* __USBIP_NETWORK_H */ diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c index 1c76cfd..7980f8b 100644 --- a/drivers/staging/usbip/userspace/src/usbipd.c +++ b/drivers/staging/usbip/userspace/src/usbipd.c @@ -56,6 +56,13 @@ static const char usbip_version_string[] = PACKAGE_STRING; static const char usbipd_help_string[] = "usage: usbipd [options]\n" + "\n" + " -4, --ipv4\n" + " Bind to IPv4. Default is both.\n" + "\n" + " -6, --ipv6\n" + " Bind to IPv6. Default is both.\n" + "\n" " -D, --daemon\n" " Run as a daemon process.\n" "\n" @@ -354,14 +361,15 @@ static void addrinfo_to_text(struct addrinfo *ai, char buf[], snprintf(buf, buf_size, "%s:%s", hbuf, sbuf); } -static int listen_all_addrinfo(struct addrinfo *ai_head, int sockfdlist[]) +static int listen_all_addrinfo(struct addrinfo *ai_head, int sockfdlist[], + int maxsockfd) { struct addrinfo *ai; int ret, nsockfd = 0; const size_t ai_buf_size = NI_MAXHOST + NI_MAXSERV + 2; char ai_buf[ai_buf_size]; - for (ai = ai_head; ai && nsockfd < MAXSOCKFD; ai = ai->ai_next) { + for (ai = ai_head; ai && nsockfd < maxsockfd; ai = ai->ai_next) { int sock; addrinfo_to_text(ai, ai_buf, ai_buf_size); dbg("opening %s", ai_buf); @@ -374,6 +382,9 @@ static int listen_all_addrinfo(struct addrinfo *ai_head, int sockfdlist[]) usbip_net_set_reuseaddr(sock); usbip_net_set_nodelay(sock); + /* We use seperate sockets for IPv4 and IPv6 + * (see do_standalone_mode()) */ + usbip_net_set_v6only(sock); if (sock >= FD_SETSIZE) { err("FD_SETSIZE: %s: sock=%d, max=%d", @@ -402,11 +413,6 @@ static int listen_all_addrinfo(struct addrinfo *ai_head, int sockfdlist[]) sockfdlist[nsockfd++] = sock; } - if (nsockfd == 0) - return -1; - - dbg("listening on %d address%s", nsockfd, (nsockfd == 1) ? "" : "es"); - return nsockfd; } @@ -473,11 +479,11 @@ static void remove_pid_file() } } -static int do_standalone_mode(int daemonize) +static int do_standalone_mode(int daemonize, int ipv4, int ipv6) { struct addrinfo *ai_head; int sockfdlist[MAXSOCKFD]; - int nsockfd; + int nsockfd, family; int i, terminate; struct pollfd *fds; struct timespec timeout; @@ -501,21 +507,36 @@ static int do_standalone_mode(int daemonize) set_signal(); write_pid_file(); - ai_head = do_getaddrinfo(NULL, PF_UNSPEC); + info("starting " PROGNAME " (%s)", usbip_version_string); + + /* + * To suppress warnings on systems with bindv6only disabled + * (default), we use seperate sockets for IPv6 and IPv4 and set + * IPV6_V6ONLY on the IPv6 sockets. + */ + if (ipv4 && ipv6) + family = AF_UNSPEC; + else if (ipv4) + family = AF_INET; + else + family = AF_INET6; + + ai_head = do_getaddrinfo(NULL, family); if (!ai_head) { usbip_host_driver_close(); return -1; } - - info("starting " PROGNAME " (%s)", usbip_version_string); - - nsockfd = listen_all_addrinfo(ai_head, sockfdlist); + nsockfd = listen_all_addrinfo(ai_head, sockfdlist, + sizeof(sockfdlist) / sizeof(*sockfdlist)); + freeaddrinfo(ai_head); if (nsockfd <= 0) { err("failed to open a listening socket"); - freeaddrinfo(ai_head); usbip_host_driver_close(); return -1; } + + dbg("listening on %d address%s", nsockfd, (nsockfd == 1) ? "" : "es"); + fds = calloc(nsockfd, sizeof(struct pollfd)); for (i = 0; i < nsockfd; i++) { fds[i].fd = sockfdlist[i]; @@ -551,7 +572,6 @@ static int do_standalone_mode(int daemonize) info("shutting down " PROGNAME); free(fds); - freeaddrinfo(ai_head); usbip_host_driver_close(); return 0; @@ -560,6 +580,9 @@ static int do_standalone_mode(int daemonize) int main(int argc, char *argv[]) { static const struct option longopts[] = { + { "ipv4", no_argument, NULL, '4' }, + { "ipv6", no_argument, NULL, '6' }, + { "daemon", no_argument, NULL, 'D' }, { "daemon", no_argument, NULL, 'D' }, { "debug", no_argument, NULL, 'd' }, { "pid", optional_argument, NULL, 'P' }, @@ -576,6 +599,7 @@ int main(int argc, char *argv[]) } cmd; int daemonize = 0; + int ipv4 = 0, ipv6 = 0; int opt, rc = -1; pid_file = NULL; @@ -587,12 +611,18 @@ int main(int argc, char *argv[]) cmd = cmd_standalone_mode; for (;;) { - opt = getopt_long(argc, argv, "DdP::t:hv", longopts, NULL); + opt = getopt_long(argc, argv, "46DdP::t:hv", longopts, NULL); if (opt == -1) break; switch (opt) { + case '4': + ipv4 = 1; + break; + case '6': + ipv6 = 1; + break; case 'D': daemonize = 1; break; @@ -618,9 +648,12 @@ int main(int argc, char *argv[]) } } + if (!ipv4 && !ipv6) + ipv4 = ipv6 = 1; + switch (cmd) { case cmd_standalone_mode: - rc = do_standalone_mode(daemonize); + rc = do_standalone_mode(daemonize, ipv4, ipv6); remove_pid_file(); break; case cmd_version: diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index d7974cb..e810ad5 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c @@ -999,12 +999,6 @@ static int vhci_hcd_probe(struct platform_device *pdev) usbip_dbg_vhci_hc("name %s id %d\n", pdev->name, pdev->id); - /* will be removed */ - if (pdev->dev.dma_mask) { - dev_info(&pdev->dev, "vhci_hcd DMA not supported\n"); - return -EINVAL; - } - /* * Allocate and initialize hcd. * Our private data is also allocated automatically. @@ -1146,11 +1140,11 @@ static int __init vhci_hcd_init(void) return -ENODEV; ret = platform_driver_register(&vhci_driver); - if (ret < 0) + if (ret) goto err_driver_register; ret = platform_device_register(&the_pdev); - if (ret < 0) + if (ret) goto err_platform_device_register; pr_info(DRIVER_DESC " v" USBIP_VERSION "\n"); |