From 55a65ed8853ba73f1f9de297e9b6e15a6f37743a Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Wed, 18 Oct 2023 17:00:39 +0000 Subject: [PATCH] LU-17217 obd: reserve server-side connection policy bits Reserve bits for new mechanism enabling server to refuse client connections based on arbitrary criterion that Lustre admins can define via policies. The policies envisioned currently are: ALLOW (allow connection to procede as normal) WARN (generate a warning on the client-side) SOFT_BLOCK (block mounting unless client overrides) HARD_BLOCK (block mounting entirely) In order to SOFT_BLOCK a client, servers need to be able to differentiate between clients that support scp and those that don't scp. Older clients would not have the mechanism to override a server-side SOFT_BLOCK, so they would HARD_BLOCK instead. We also need a bitmask for the client/server to communciate policy opinions (i.e. don't soft-block me). Therefore, this patch reserves: 1) OBD_CONNECT2_CONN_POLICY 2) 8 bits of obd_connect_data It also explicitly defines the use of some of the bits via an enum. Test-Parameters: trivial Signed-off-by: Timothy Day Change-Id: If717045728e516eece7c2d812f8ee6e7ebba9497 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52793 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin --- lustre/include/uapi/linux/lustre/lustre_idl.h | 13 ++++++++++++- lustre/obdclass/lprocfs_status.c | 1 + lustre/ptlrpc/wiretest.c | 10 ++++++++-- lustre/utils/wirecheck.c | 2 ++ lustre/utils/wiretest.c | 10 ++++++++-- 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lustre/include/uapi/linux/lustre/lustre_idl.h b/lustre/include/uapi/linux/lustre/lustre_idl.h index 3b012b8..5630acb 100644 --- a/lustre/include/uapi/linux/lustre/lustre_idl.h +++ b/lustre/include/uapi/linux/lustre/lustre_idl.h @@ -865,6 +865,7 @@ struct ptlrpc_body_v2 { * ignored for ldiskfs servers */ #define OBD_CONNECT2_UNALIGNED_DIO 0x400000000ULL /* unaligned DIO */ +#define OBD_CONNECT2_CONN_POLICY 0x800000000ULL /* server-side connection policy */ /* XXX README XXX README XXX README XXX README XXX README XXX README XXX * Please DO NOT add OBD_CONNECT flags before first ensuring that this value * is not in use by some other branch/patch. Email adilger@whamcloud.com @@ -1006,7 +1007,8 @@ struct obd_connect_data { * may result in out-of-bound memory access and kernel oops. */ __u16 ocd_maxmodrpcs; /* Maximum modify RPCs in parallel */ - __u16 padding0; /* READ BELOW! also fix lustre_swab_connect */ + __u8 ocd_conn_policy; /* bitmask for client/server to communicate about policy */ + __u8 padding0; /* READ BELOW! also fix lustre_swab_connect */ __u32 padding1; /* READ BELOW! also fix lustre_swab_connect */ __u64 ocd_connect_flags2;/* OBD_CONNECT2_* per above */ __u64 ocd_compr_type; /* bitmask of supported compression types */ @@ -1068,6 +1070,15 @@ enum cksum_types { #define OBD_CKSUM_T10_TOP OBD_CKSUM_ADLER /* + * Explicitly define the meaning of the bits in ocd_conn_policy, + * for server-side connection policy. + */ +enum conn_policy_flags { + BYPASS_SOFT_BLOCK = 0, + CONN_POLICY_FLAGS_NUM = 8, +}; + +/* * OST requests: OBDO & OBD request records */ diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 3aa4b9e..c2305b9 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -658,6 +658,7 @@ static const char *const obd_connect_names[] = { "large_nid", /* 0x100000000 */ "compressed_file", /* 0x200000000 */ "unaligned_dio", /* 0x400000000 */ + "conn_policy", /* 0x800000000 */ NULL }; diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index fca228a..5cafbf3 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -1207,9 +1207,13 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct obd_connect_data, ocd_maxmodrpcs)); LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_maxmodrpcs) == 2, "found %lld\n", (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_maxmodrpcs)); - LASSERTF((int)offsetof(struct obd_connect_data, padding0) == 74, "found %lld\n", + LASSERTF((int)offsetof(struct obd_connect_data, ocd_conn_policy) == 74, "found %lld\n", + (long long)(int)offsetof(struct obd_connect_data, ocd_conn_policy)); + LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_conn_policy) == 1, "found %lld\n", + (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_conn_policy)); + LASSERTF((int)offsetof(struct obd_connect_data, padding0) == 75, "found %lld\n", (long long)(int)offsetof(struct obd_connect_data, padding0)); - LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding0) == 2, "found %lld\n", + LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding0) == 1, "found %lld\n", (long long)(int)sizeof(((struct obd_connect_data *)0)->padding0)); LASSERTF((int)offsetof(struct obd_connect_data, padding1) == 76, "found %lld\n", (long long)(int)offsetof(struct obd_connect_data, padding1)); @@ -1459,6 +1463,8 @@ void lustre_assert_wire_constants(void) OBD_CONNECT2_COMPRESS); LASSERTF(OBD_CONNECT2_UNALIGNED_DIO == 0x400000000ULL, "found 0x%.16llxULL\n", OBD_CONNECT2_UNALIGNED_DIO); + LASSERTF(OBD_CONNECT2_CONN_POLICY == 0x800000000ULL, "found 0x%.16llxULL\n", + OBD_CONNECT2_CONN_POLICY); LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n", (unsigned)OBD_CKSUM_CRC32); diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index 1cdf551..6c6b62c 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -572,6 +572,7 @@ check_obd_connect_data(void) CHECK_MEMBER(obd_connect_data, ocd_instance); CHECK_MEMBER(obd_connect_data, ocd_maxbytes); CHECK_MEMBER(obd_connect_data, ocd_maxmodrpcs); + CHECK_MEMBER(obd_connect_data, ocd_conn_policy); CHECK_MEMBER(obd_connect_data, padding0); CHECK_MEMBER(obd_connect_data, padding1); CHECK_MEMBER(obd_connect_data, ocd_connect_flags2); @@ -684,6 +685,7 @@ check_obd_connect_data(void) CHECK_DEFINE_64X(OBD_CONNECT2_LARGE_NID); CHECK_DEFINE_64X(OBD_CONNECT2_COMPRESS); CHECK_DEFINE_64X(OBD_CONNECT2_UNALIGNED_DIO); + CHECK_DEFINE_64X(OBD_CONNECT2_CONN_POLICY); BLANK_LINE(); CHECK_VALUE_X(OBD_CKSUM_CRC32); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 72dee0d..c320e4b 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -1232,9 +1232,13 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct obd_connect_data, ocd_maxmodrpcs)); LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_maxmodrpcs) == 2, "found %lld\n", (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_maxmodrpcs)); - LASSERTF((int)offsetof(struct obd_connect_data, padding0) == 74, "found %lld\n", + LASSERTF((int)offsetof(struct obd_connect_data, ocd_conn_policy) == 74, "found %lld\n", + (long long)(int)offsetof(struct obd_connect_data, ocd_conn_policy)); + LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_conn_policy) == 1, "found %lld\n", + (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_conn_policy)); + LASSERTF((int)offsetof(struct obd_connect_data, padding0) == 75, "found %lld\n", (long long)(int)offsetof(struct obd_connect_data, padding0)); - LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding0) == 2, "found %lld\n", + LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding0) == 1, "found %lld\n", (long long)(int)sizeof(((struct obd_connect_data *)0)->padding0)); LASSERTF((int)offsetof(struct obd_connect_data, padding1) == 76, "found %lld\n", (long long)(int)offsetof(struct obd_connect_data, padding1)); @@ -1484,6 +1488,8 @@ void lustre_assert_wire_constants(void) OBD_CONNECT2_COMPRESS); LASSERTF(OBD_CONNECT2_UNALIGNED_DIO == 0x400000000ULL, "found 0x%.16llxULL\n", OBD_CONNECT2_UNALIGNED_DIO); + LASSERTF(OBD_CONNECT2_CONN_POLICY == 0x800000000ULL, "found 0x%.16llxULL\n", + OBD_CONNECT2_CONN_POLICY); LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n", (unsigned)OBD_CKSUM_CRC32); -- 1.8.3.1