Commit 0fbbced2 authored by Liang Zhen's avatar Liang Zhen Committed by Greg Kroah-Hartman

staging: lustre: LNet drop rule implementation

This is implementation of LNet Drop Rule, which can randomly drop
LNet messages at specified rate.

LNet Drop Rule can only be applied to receive side of message. User
can add drop_rule either on end point of cluster (client/server) or
on LNet routers.

Here are lctl command to control LNet Drop Rules:
 - net_drop_add -s SRC_NID -d DEST_NID --rate VALUE
   drop 1/@VALUE of messages from @SRC_NID to @DEST_NID

 - net_drop_del -s SRC_NID -d DEST_NID
   remove all drop rules from @SRC_NID to @DEST_NID

 - net_drop_list
   list all drop rules on current node

 Examples:
 - lctl net_drop_add -s *@o2ib0 -d 192.168.1.102@tcp 1000
   add new drop rule, it will drop 1/1000 messages from network o2ib0
   to 192.168.1.102@tcp

 - lctl net_drop_add -s 10.8.6.123@o2ib1 -d * 500
   add new drop rule, it will drop 1/500 messages from 10.8.6.123@o2ib1
   to all nodes
Signed-off-by: default avatarLiang Zhen <liang.zhen@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5435
Reviewed-on: http://review.whamcloud.com/11314Reviewed-by: default avatarBobi Jam <bobijam@gmail.com>
Reviewed-by: default avatarAmir Shehata <amir.shehata@intel.com>
Reviewed-by: default avatarJohann Lombardi <johann.lombardi@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a921e9bd
......@@ -121,6 +121,7 @@ struct libcfs_ioctl_handler {
#define IOC_LIBCFS_PING _IOWR('e', 61, long)
/* #define IOC_LIBCFS_DEBUG_PEER _IOWR('e', 62, long) */
#define IOC_LIBCFS_LNETST _IOWR('e', 63, long)
#define IOC_LIBCFS_LNET_FAULT _IOWR('e', 64, long)
/* lnd ioctls */
#define IOC_LIBCFS_REGISTER_MYNID _IOWR('e', 70, long)
#define IOC_LIBCFS_CLOSE_CONNECTION _IOWR('e', 71, long)
......
......@@ -578,6 +578,16 @@ char *lnet_msgtyp2str(int type);
void lnet_print_hdr(lnet_hdr_t *hdr);
int lnet_fail_nid(lnet_nid_t nid, unsigned int threshold);
/** \addtogroup lnet_fault_simulation @{ */
int lnet_fault_ctl(int cmd, struct libcfs_ioctl_data *data);
int lnet_fault_init(void);
void lnet_fault_fini(void);
bool lnet_drop_rule_match(lnet_hdr_t *hdr);
/** @} lnet_fault_simulation */
void lnet_counters_get(lnet_counters_t *counters);
void lnet_counters_reset(void);
......
......@@ -40,6 +40,7 @@
#include <linux/types.h>
#include "types.h"
#include "lnetctl.h"
/* Max payload size */
#define LNET_MAX_PAYLOAD CONFIG_LNET_MAX_PAYLOAD
......@@ -572,6 +573,7 @@ typedef struct {
struct lnet_peer_table **ln_peer_tables;
/* failure simulation */
struct list_head ln_test_peers;
struct list_head ln_drop_rules;
struct list_head ln_nis; /* LND instances */
/* NIs bond on specific CPT(s) */
......
......@@ -17,6 +17,89 @@
#include "types.h"
/** \addtogroup lnet_fault_simulation
* @{
*/
enum {
LNET_CTL_DROP_ADD,
LNET_CTL_DROP_DEL,
LNET_CTL_DROP_RESET,
LNET_CTL_DROP_LIST,
};
#define LNET_ACK_BIT BIT(0)
#define LNET_PUT_BIT BIT(1)
#define LNET_GET_BIT BIT(2)
#define LNET_REPLY_BIT BIT(3)
/** ioctl parameter for LNet fault simulation */
struct lnet_fault_attr {
/**
* source NID of drop rule
* LNET_NID_ANY is wildcard for all sources
* 255.255.255.255@net is wildcard for all addresses from @net
*/
lnet_nid_t fa_src;
/** destination NID of drop rule, see \a dr_src for details */
lnet_nid_t fa_dst;
/**
* Portal mask to drop, -1 means all portals, for example:
* fa_ptl_mask = (1 << _LDLM_CB_REQUEST_PORTAL ) |
* (1 << LDLM_CANCEL_REQUEST_PORTAL)
*
* If it is non-zero then only PUT and GET will be filtered, otherwise
* there is no portal filter, all matched messages will be checked.
*/
__u64 fa_ptl_mask;
/**
* message types to drop, for example:
* dra_type = LNET_DROP_ACK_BIT | LNET_DROP_PUT_BIT
*
* If it is non-zero then only specified message types are filtered,
* otherwise all message types will be checked.
*/
__u32 fa_msg_mask;
union {
/** message drop simulation */
struct {
/** drop rate of this rule */
__u32 da_rate;
/**
* time interval of message drop, it is exclusive
* with da_rate
*/
__u32 da_interval;
} drop;
/** TODO: add more */
__u64 space[8];
} u;
};
/** fault simluation stats */
struct lnet_fault_stat {
/** total # matched messages */
__u64 fs_count;
/** # dropped LNET_MSG_PUT by this rule */
__u64 fs_put;
/** # dropped LNET_MSG_ACK by this rule */
__u64 fs_ack;
/** # dropped LNET_MSG_GET by this rule */
__u64 fs_get;
/** # dropped LNET_MSG_REPLY by this rule */
__u64 fs_reply;
union {
struct {
/** total # dropped messages */
__u64 ds_dropped;
} drop;
/** TODO: add more */
__u64 space[8];
} u;
};
/** @} lnet_fault_simulation */
#define LNET_DEV_ID 0
#define LNET_DEV_PATH "/dev/lnet"
#define LNET_DEV_MAJOR 10
......
obj-$(CONFIG_LNET) += lnet.o
lnet-y := api-ni.o config.o nidstrings.o \
lnet-y := api-ni.o config.o nidstrings.o net_fault.o \
lib-me.o lib-msg.o lib-eq.o lib-md.o lib-ptl.o \
lib-socket.o lib-move.o module.o lo.o \
router.o router_proc.o acceptor.o peer.o
......@@ -550,6 +550,7 @@ lnet_prepare(lnet_pid_t requested_pid)
INIT_LIST_HEAD(&the_lnet.ln_nis_cpt);
INIT_LIST_HEAD(&the_lnet.ln_nis_zombie);
INIT_LIST_HEAD(&the_lnet.ln_routers);
INIT_LIST_HEAD(&the_lnet.ln_drop_rules);
rc = lnet_create_remote_nets_table();
if (rc)
......@@ -1564,6 +1565,7 @@ LNetNIInit(lnet_pid_t requested_pid)
if (rc)
goto err_stop_ping;
lnet_fault_init();
lnet_router_debugfs_init();
mutex_unlock(&the_lnet.ln_api_mutex);
......@@ -1616,6 +1618,7 @@ LNetNIFini(void)
} else {
LASSERT(!the_lnet.ln_niinit_self);
lnet_fault_fini();
lnet_router_debugfs_fini();
lnet_router_checker_stop();
lnet_ping_target_fini();
......@@ -2030,6 +2033,9 @@ LNetCtl(unsigned int cmd, void *arg)
lnet_net_unlock(LNET_LOCK_EX);
return 0;
case IOC_LIBCFS_LNET_FAULT:
return lnet_fault_ctl(data->ioc_flags, data);
case IOC_LIBCFS_PING:
id.nid = data->ioc_nid;
id.pid = data->ioc_u32[0];
......
......@@ -1931,6 +1931,14 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
goto drop;
}
if (!list_empty(&the_lnet.ln_drop_rules) &&
lnet_drop_rule_match(hdr)) {
CDEBUG(D_NET, "%s, src %s, dst %s: Dropping %s to simulate silent message loss\n",
libcfs_nid2str(from_nid), libcfs_nid2str(src_nid),
libcfs_nid2str(dest_nid), lnet_msgtyp2str(type));
goto drop;
}
msg = lnet_msg_alloc();
if (!msg) {
CERROR("%s, src %s: Dropping %s (out of memory)\n",
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment