Debian Codegraph @

doc/antora/modules/developers/pages/protocol-error.adoc

raw
1 = Protocol-Error Implementation
2
3 The following is a set of notes for implementing Protocol-Error in FreeRADIUS 3.2.
4
5 == Client Configuration
6
7 Each client now has an additional configuration option:
8
9 ```
10 protocol_error = yes # default is "no"
11 ```
12
13 This configuration option is also exposed as in internal attribute for dynamic clients.
14
15 The purpose of this option is to control whether or not we send a
16 Protocol-Error response to the client. Previous versions of the
17 server would synthesize an Access-Reject in some circumstances, and we
18 don't want to change that behavior in a stable release.
19
20 All new behavior for sending Protocol-Error to a client is enabled by
21 setting this flag.
22
23 == Encoder / Decoder
24
25 The encoder and decoder have been updated to allow Protocol-Error.
26
27 === Encoder
28
29 The encoder has been updated to encode Protocol-Error as response
30 packets. The encoding method used is the same as for Access-Accept,
31 etc. This encoding means that Message-Authenticator is also added for
32 all Protocol-Error packets, even for ones which are in response to
33 Accounting-Request. We may be OK with relaxing this requirement in
34 the future.
35
36 The only magic in the encoder is that it automatically adds
37 `Original-Packet-Code`. This attribute allows the client to associate
38 the Protocol-Error responsewith (e.g.) Access-Request or
39 Accounting-Request, even if both of those packets contain the same ID.
40
41 i.e. there is no need for the RADIUS policies to add
42 Original-Packet-Code. Since that attribute is required for protocol
43 compliance, the encoder adds it automatically.
44
45 FreeRADIUS tracks packets by ID, and not by packet Code. So this
46 attribute isn't necessary. But maybe other RADIUS implementations need
47 it.
48
49 === Decoder
50
51 The decoder has been updated to decode Protocol-Error as response
52 packets for any request.
53
54 Other than that, the decoder did not require any changes.
55
56 == radclient
57
58 radclient was updated to explicitly accept Protocol-Error as a
59 response to Access-Request packets. Note that only the BlastRADIUS
60 checks needed to be updated, because they checked the packet codes
61 before calling the decoder.
62
63 Since the decoder was updated to allow Protocol-Error, no additional
64 changes to radclient were needed.
65
66 == Server
67
68 The server had a number of changes in order to support Protocol-Error.
69
70 === Input Queue
71
72 When the server is busy and cannot enqueue a new packet, it previously
73 just discarded the request.
74
75 It now checks if the client supports Protocol-Error. If so, it
76 immediately encodes and sends a Protocol-Error response. The request
77 is also marked up as done/completed/cleaned-up immediately. Since the
78 server is busy, there isn't much utility in caching the packet for a
79 "cleanup delay".
80
81 NOTE: We may want to add "cleanup delay" handling in the future.
82
83 === Modules
84
85 The `realm` module has been updated to configurable return `notfound`
86 when the destination realm isn't found. As this is a behavior change,
87 it is hidden behind a new module configuration flag
88
89 ```
90 return_notfound = yes # default is "no"
91 ```
92
93 === Default Virtual Server
94
95 The `default` virtual server has been updated with a commented-out
96 configuration for Protocol-Error. The configuration is after the
97 `suffix` module, which is used for routing packets based on realms:
98
99 ```
100 authorize {
101 ...
102 suffix
103 if (notfound && ("%{client:protocol_error}" == "yes")) {
104 update {
105 &control:Response-Packet-Type := Protocol-Error
106 &reply:Error-Cause := Proxy-Request-Not-Routable
107 }
108 handled
109 }
110 ...
111 }
112 ```
113
114 === Proxied Requests
115
116 No changes are made to proxied requests.
117
118 === Proxied Responses
119
120 The server always accepts Protocol-Error as a response to any proxied
121 request. This behavior is not configurable. There doesn't seem to be
122 any good reason to ignore/discard Protocol-Error responses.
123
124 If the server never receives a reply from the home server, it checks
125 if the client can receive Protocol-Error. If so, it synthesizes a
126 Protocol-Error reply, and runs it through the "proxcess proxy reply"
127 functionality. It also adds an Error-Cause with a value that is
128 appropriate for what happened.
129
130 If the server never receives a reply from the home server, a policy in
131 the Post-Proxy-Type section can still manually create a Protocol-Error
132 packet. This is allowed because maybe there's a situation where
133 checking the client `protocol_error` flag isn't enough. Again, it
134 also adds (if necessary) an Error-Cause with a value that is
135 appropriate for what happened. If the policy added Error-Cause, then
136 that value isn't changed.
137
138 NOTE: The server does not re-proxy the packet if it receives a
139 Protocol-Error response from the home server.
140
141 === Finished Processing, Sending Response
142
143 Once a request is done processing, a response is sent. Since not all
144 clients support Protocol-Error, the code checks if a policy (or home
145 server) created a Protocol-Error response. If it is there, the packet
146 code is mashed to "no reply".
147
148 This change allows the rest of the code to determine what response (if
149 any) is sent. For example, the historic behavior for Access-Request
150 is to send a synthesized Access-Reject.
151