1nbd_set_strict_mode(3)              LIBNBD              nbd_set_strict_mode(3)
2
3
4

NAME

6       nbd_set_strict_mode - control how strictly to follow NBD protocol
7

SYNOPSIS

9        #include <libnbd.h>
10
11        int nbd_set_strict_mode (struct nbd_handle *h,
12                                 uint32_t flags);
13

DESCRIPTION

15       By default, libnbd tries to detect requests that would trigger
16       undefined behavior in the NBD protocol, and rejects them client side
17       without causing any network traffic, rather than risking undefined
18       server behavior.  However, for integration testing, it can be handy to
19       relax the strictness of libnbd, to coerce it into sending such requests
20       over the network for testing the robustness of the server in dealing
21       with such traffic.
22
23       The "flags" argument is a bitmask, including zero or more of the
24       following strictness flags:
25
26       "LIBNBD_STRICT_COMMANDS" = 0x1
27           If set, this flag rejects client requests that do not comply with
28           the set of advertised server flags (for example, attempting a write
29           on a read-only server, or attempting to use "LIBNBD_CMD_FLAG_FUA"
30           when nbd_can_fua(3) returned false).  If clear, this flag relies on
31           the server to reject unexpected commands.
32
33       "LIBNBD_STRICT_FLAGS" = 0x2
34           If set, this flag rejects client requests that attempt to set a
35           command flag not recognized by libnbd (those outside of
36           "LIBNBD_CMD_FLAG_MASK"), or a flag not normally associated with a
37           command (such as using "LIBNBD_CMD_FLAG_FUA" on a read command).
38           If clear, all flags are sent on to the server, even if sending such
39           a flag may cause the server to change its reply in a manner that
40           confuses libnbd, perhaps causing deadlock or ending the connection.
41
42           Flags that are known by libnbd as associated with a given command
43           (such as "LIBNBD_CMD_FLAG_DF" for nbd_pread_structured(3) gated by
44           nbd_can_df(3)) are controlled by "LIBNBD_STRICT_COMMANDS" instead.
45
46           Note that the NBD protocol only supports 16 bits of command flags,
47           even though the libnbd API uses "uint32_t"; bits outside of the
48           range permitted by the protocol are always a client-side error.
49
50       "LIBNBD_STRICT_BOUNDS" = 0x4
51           If set, this flag rejects client requests that would exceed the
52           export bounds without sending any traffic to the server.  If clear,
53           this flag relies on the server to detect out-of-bounds requests.
54
55       "LIBNBD_STRICT_ZERO_SIZE" = 0x8
56           If set, this flag rejects client requests with length 0.  If clear,
57           this permits zero-length requests to the server, which may produce
58           undefined results.
59
60       "LIBNBD_STRICT_ALIGN" = 0x10
61           If set, and the server provided minimum block sizes (see
62           nbd_get_block_size(3), this flag rejects client requests that do
63           not have length and offset aligned to the server's minimum
64           requirements.  If clear, unaligned requests are sent to the server,
65           where it is up to the server whether to honor or reject the
66           request.
67
68       For convenience, the constant "LIBNBD_STRICT_MASK" is available to
69       describe all strictness flags supported by this build of libnbd.
70       Future versions of libnbd may add further flags, which are likely to be
71       enabled by default for additional client-side filtering.  As such, when
72       attempting to relax only one specific bit while keeping remaining
73       checks at the client side, it is wiser to first call
74       nbd_get_strict_mode(3) and modify that value, rather than blindly
75       setting a constant value.
76

RETURN VALUE

78       If the call is successful the function returns 0.
79

ERRORS

81       On error "-1" is returned.
82
83       Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
84       of the error.
85
86       The following parameters must not be NULL: "h".  For more information
87       see "Non-NULL parameters" in libnbd(3).
88

VERSION

90       This function first appeared in libnbd 1.6.
91
92       If you need to test if this function is available at compile time check
93       if the following macro is defined:
94
95        #define LIBNBD_HAVE_NBD_SET_STRICT_MODE 1
96

SEE ALSO

98       nbd_can_df(3), nbd_can_fua(3), nbd_create(3), nbd_get_block_size(3),
99       nbd_get_strict_mode(3), nbd_pread_structured(3),
100       nbd_set_handshake_flags(3), libnbd(3).
101

AUTHORS

103       Eric Blake
104
105       Richard W.M. Jones
106
108       Copyright (C) 2019-2021 Red Hat Inc.
109

LICENSE

111       This library is free software; you can redistribute it and/or modify it
112       under the terms of the GNU Lesser General Public License as published
113       by the Free Software Foundation; either version 2 of the License, or
114       (at your option) any later version.
115
116       This library is distributed in the hope that it will be useful, but
117       WITHOUT ANY WARRANTY; without even the implied warranty of
118       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
119       Lesser General Public License for more details.
120
121       You should have received a copy of the GNU Lesser General Public
122       License along with this library; if not, write to the Free Software
123       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
124       02110-1301 USA
125
126
127
128libnbd-1.14.2                     2023-01-03            nbd_set_strict_mode(3)
Impressum