Whamcloud - gitweb
LU-2456 lnet: Dynamic LNet Configuration (DLC) show command
[fs/lustre-release.git] / libcfs / libcfs / module.c
index 8eeca56..16d0a16 100644 (file)
  */
 
 #define DEBUG_SUBSYSTEM S_LNET
-/* TODO - This will be completed in the subsequent patches.
- * For this patch the MAX is hardcoded, in the next patch
- * the value will be set to the largest data structure that
- * can be sent from user space */
-#define LIBCFS_MAX_IOCTL_BUF_LEN 2048
+#define LNET_MAX_IOCTL_BUF_LEN (sizeof(struct lnet_ioctl_net_config) + \
+                                sizeof(struct lnet_ioctl_config_data))
 
 #include <libcfs/libcfs.h>
 #include <libcfs/libcfs_crypto.h>
 #include <lnet/lib-lnet.h>
+#include <lnet/lib-dlc.h>
 #include <lnet/lnet.h>
 #include "tracefile.h"
 
@@ -230,10 +228,11 @@ static int libcfs_ioctl_handle(struct cfs_psdev_file *pfile, unsigned long cmd,
        int err;
        ENTRY;
 
-       /* TODO: this is going to change in subsequent patches
-        * to exclude messages which use the new data structures */
-       if ((cmd <= IOC_LIBCFS_LNETST) ||
-           (cmd >= IOC_LIBCFS_REGISTER_MYNID)) {
+       /* The libcfs_ioctl_data_adjust() function performs adjustment
+        * operations on the libcfs_ioctl_data structure to make
+        * it usable by the code.  This doesn't need to be called
+        * for new data structures added. */
+       if (hdr->ioc_version == LIBCFS_IOCTL_VERSION) {
                data = container_of(hdr, struct libcfs_ioctl_data, ioc_hdr);
                err = libcfs_ioctl_data_adjust(data);
                if (err != 0) {
@@ -325,7 +324,7 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile,
         * do a check here to restrict the size of the memory
         * to allocate to guard against DoS attacks.
         */
-       if (buf_len > LIBCFS_MAX_IOCTL_BUF_LEN) {
+       if (buf_len > LNET_MAX_IOCTL_BUF_LEN) {
                CERROR("LNET: user buffer exceeds kernel buffer\n");
                RETURN(-EINVAL);
        }