Whamcloud - gitweb
LU-11838: lnet: remove lnet_ipif_enumerate() 34/34234/3
authorNeilBrown <neilb@suse.com>
Wed, 20 Mar 2019 19:25:24 +0000 (15:25 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 29 May 2019 04:24:58 +0000 (04:24 +0000)
Also remove lnet_ipif_query() and related functions.

There are no longer any users of these functions, so remove them.

Linux-commit: 6e659fcfab0cdd876a555a752acf9997f98acbcd

Change-Id: I8183e505e3dbe12ff71ddf38f5b18a945d8a4a6c
Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-on: https://review.whamcloud.com/34234
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-by: Aurelien Degremont <degremoa@amazon.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/include/lnet/lib-lnet.h
lnet/lnet/lib-socket.c

index a829103..cd2b608 100644 (file)
@@ -840,9 +840,6 @@ int lnet_acceptor_port(void);
 int lnet_acceptor_start(void);
 void lnet_acceptor_stop(void);
 
-int lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
-int lnet_ipif_enumerate(char ***names);
-void lnet_ipif_free_enumeration(char **names, int n);
 int lnet_sock_setbuf(struct socket *socket, int txbufsize, int rxbufsize);
 int lnet_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize);
 int lnet_sock_getaddr(struct socket *socket, bool remote, __u32 *ip, int *port);
index 8afc4b5..85bb413 100644 (file)
 #include <libcfs/libcfs.h>
 #include <lnet/lib-lnet.h>
 
-static int
-lnet_sock_ioctl(int cmd, unsigned long arg)
-{
-       struct socket *sock;
-       int rc;
-
-#ifdef HAVE_SOCK_CREATE_KERN_USE_NET
-       rc = sock_create_kern(&init_net, PF_INET, SOCK_STREAM, 0, &sock);
-#else
-       rc = sock_create_kern(PF_INET, SOCK_STREAM, 0, &sock);
-#endif
-       if (rc != 0) {
-               CERROR("Can't create socket: %d\n", rc);
-               return rc;
-       }
-
-       if (cmd == SIOCGIFFLAGS) {
-               /* This cmd is used only to get IFF_UP flag */
-               struct ifreq *ifr = (struct ifreq *) arg;
-               struct net_device *dev;
-
-               dev = dev_get_by_name(sock_net(sock->sk), ifr->ifr_name);
-               if (dev) {
-                       ifr->ifr_flags = dev->flags;
-                       dev_put(dev);
-                       rc = 0;
-               } else {
-                       rc = -ENODEV;
-               }
-       } else {
-               rc = kernel_sock_ioctl(sock, cmd, arg);
-       }
-       sock_release(sock);
-
-       return rc;
-}
-
-int
-lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask)
-{
-       struct ifreq    ifr;
-       int             nob;
-       int             rc;
-       __u32           val;
-
-       nob = strnlen(name, IFNAMSIZ);
-       if (nob == IFNAMSIZ) {
-               CERROR("Interface name %s too long\n", name);
-               return -EINVAL;
-       }
-
-       CLASSERT(sizeof(ifr.ifr_name) >= IFNAMSIZ);
-
-       if (strlen(name) > sizeof(ifr.ifr_name)-1)
-               return -E2BIG;
-       strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
-
-       rc = lnet_sock_ioctl(SIOCGIFFLAGS, (unsigned long)&ifr);
-       if (rc != 0) {
-               CERROR("Can't get flags for interface %s\n", name);
-               return rc;
-       }
-
-       if ((ifr.ifr_flags & IFF_UP) == 0) {
-               CDEBUG(D_NET, "Interface %s down\n", name);
-               *up = 0;
-               *ip = *mask = 0;
-               return 0;
-       }
-       *up = 1;
-
-       if (strlen(name) > sizeof(ifr.ifr_name)-1)
-               return -E2BIG;
-       strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
-
-       ifr.ifr_addr.sa_family = AF_INET;
-       rc = lnet_sock_ioctl(SIOCGIFADDR, (unsigned long)&ifr);
-
-       if (rc != 0) {
-               CERROR("Can't get IP address for interface %s\n", name);
-               return rc;
-       }
-
-       val = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
-       *ip = ntohl(val);
-
-       if (strlen(name) > sizeof(ifr.ifr_name)-1)
-               return -E2BIG;
-       strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
-
-       ifr.ifr_addr.sa_family = AF_INET;
-       rc = lnet_sock_ioctl(SIOCGIFNETMASK, (unsigned long)&ifr);
-       if (rc != 0) {
-               CERROR("Can't get netmask for interface %s\n", name);
-               return rc;
-       }
-
-       val = ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr.s_addr;
-       *mask = ntohl(val);
-
-       return 0;
-}
-EXPORT_SYMBOL(lnet_ipif_query);
-
-void
-lnet_ipif_free_enumeration(char **names, int n)
-{
-       int     i;
-
-       LASSERT(n > 0);
-
-       for (i = 0; i < n && names[i] != NULL; i++)
-               LIBCFS_FREE(names[i], IFNAMSIZ);
-
-       LIBCFS_FREE(names, n * sizeof(*names));
-}
-EXPORT_SYMBOL(lnet_ipif_free_enumeration);
-
-int
-lnet_ipif_enumerate(char ***namesp)
-{
-       /* Allocate and fill in 'names', returning # interfaces/error */
-       struct net_device *dev;
-       struct socket *sock;
-       char **names;
-       int toobig;
-       int nalloc;
-       int nfound;
-       int rc;
-       int nob;
-       int i;
-
-       nalloc = 16;    /* first guess at max interfaces */
-       toobig = 0;
-       nfound = 0;
-
-#ifdef HAVE_SOCK_CREATE_KERN_USE_NET
-       rc = sock_create_kern(&init_net, PF_INET, SOCK_STREAM, 0, &sock);
-#else
-       rc = sock_create_kern(PF_INET, SOCK_STREAM, 0, &sock);
-#endif
-       if (rc) {
-               CERROR("Can't create socket: %d\n", rc);
-               return rc;
-       }
-
-       for_each_netdev(sock_net(sock->sk), dev)
-               nfound++;
-
-       if (nfound == 0)
-               goto out_release_sock;
-
-       LIBCFS_ALLOC(names, nfound * sizeof(*names));
-       if (names == NULL) {
-               rc = -ENOMEM;
-               goto out_release_sock;
-       }
-
-       i = 0;
-       for_each_netdev(sock_net(sock->sk), dev) {
-               nob = strnlen(dev->name, IFNAMSIZ);
-               if (nob == IFNAMSIZ) {
-                       /* no space for terminating NULL */
-                       CERROR("interface name %.*s too long (%d max)\n",
-                              nob, dev->name, IFNAMSIZ);
-                       rc = -ENAMETOOLONG;
-                       goto out_free_names;
-               }
-
-               LIBCFS_ALLOC(names[i], IFNAMSIZ);
-               if (!names[i]) {
-                       rc = -ENOMEM;
-                       goto out_free_names;
-               }
-
-               memcpy(names[i], dev->name, nob);
-               names[i][nob] = 0;
-               i++;
-       }
-
-       *namesp = names;
-       rc = i;
-
-out_free_names:
-       if (rc < 0)
-               lnet_ipif_free_enumeration(names, nfound);
-out_release_sock:
-       sock_release(sock);
-       return rc;
-}
-EXPORT_SYMBOL(lnet_ipif_enumerate);
-
 int
 lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout)
 {